I accidentally discovered a difference between 2.0 and 1.1, and wrote it down to remind everyone.
It’s about generating code for the front page. We know that asp.net server controls will eventually be interpreted into the front-end javascript scripts and html codes. For example, the "datagrid" control will be interpreted into the "table" label, and the "CheckBox" control will be interpreted into "<input type='checkbox'... …"Label. Both asp.net2.0 and asp.net1.1 have this mechanism, so we can often use this mechanism to write some javascript scripts in the front desk to operate the html tags generated after these interpretations, and to call some events. I don’t know if you often use this method, but I often use this method and never tire of it.
An accidental incident found a problem. I directly copied some js scripts under 1.1 and used them in projects under 2.0. I found errors and script errors. I couldn't figure it out. Then I studied asp.net2 carefully. 0 generated frontend code, the secret was discovered. Under asp.net, after the server control in the datagrid template column is interpreted, the generated label will generate a new ID based on the ID of the original server control.
For example (under asp.net1.1), the CheckBox control is used in the template column of the DataGrid control:
<asp:datagrid id="myDataGrid" runat="server" AutoGenerateColumns="False" Height="100%" Width="100%"
EnableViewState="false">
<AlternatingItemStyle CssClass="list_bai"></AlternatingItemStyle>
<ItemStyle CssClass="list_lan"></ItemStyle>
<HeaderStyle CssClass="list_1"></HeaderStyle>
<Columns>
<asp:BoundColumn DataField="COLOR_ID" HeaderStyle-CssClass="disTd" ItemStyle-CssClass="disTd"></asp:BoundColumn>
<asp:TemplateColumn HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderText="Select<input type='checkbox' id='' onclick='doSelectAll();' title='Select All'>">
<HeaderStyle HorizontalAlign="Center" CssClass="list_1"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" CssClass="list_td"></ItemStyle>
<ItemTemplate>
<asp:CheckBox id="CheckBox1" runat="server"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:HyperLinkColumn DataNavigateUrlField="COLOR_ID" DataNavigateUrlFormatString="InfoCOLOR.aspx?id={0}&flag=0"
DataTextField="COLOR_NAME" HeaderText="Color name">
<HeaderStyle HorizontalAlign="Center" CssClass="list_1"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" CssClass="list_td"></ItemStyle>
</asp:HyperLinkColumn>
<asp:BoundColumn DataField="COLOR_CODE" HeaderText="Color HTML Coding">
<HeaderStyle HorizontalAlign="Center" CssClass="list_1"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" CssClass="list_td"></ItemStyle>
</asp:BoundColumn>
</Columns>
</asp:datagrid>
After explaining the html at the front desk, it becomes:
<table cellspacing="0" rules="all" border="1" id="myDataGrid" style="height:100%;width:100%;border-collapse:collapse;">
<tr class="list_1">
<td class="disTd"> </td>
<td class="list_1" align="Center">Select<input type='checkbox' id='' onclick='doSelectAll();' title='Select All'></td>
<td class="list_1" align="Center">Color name</td>
<td class="list_1" align="Center">Color HTML encoding</td>
</tr>
<tr class="list_lan">
<td class="disTd">16</td>
<td class="list_td" align="Center"> <input id="myDataGrid__ctl2_CheckBox1" type="checkbox" name="myDataGrid:_ctl2:CheckBox1" /></td>
<td class="list_td" align="Center"><a href="InfoCOLOR.aspx?id=16&flag=0">213`</a></td>
<td class="list_td" align="Center">123123</td>
</tr>
</table>
We can see that the DataGrid control has become a Table label, the id remains unchanged, and the original
<asp:CheckBox id="CheckBox1" runat="server"></asp:CheckBox>
It becomes
<input id="myDataGrid__ctl2_CheckBox1" type="checkbox" name="myDataGrid:_ctl2:CheckBox1" />
The "myDataGrid__ctl2_CheckBox1" here is automatically added by asp.net. It is generated by combining the id of the DataGrid where it is located, its own id and the row where the data is bound.
The above results were generated under asp.net1.1. The id generated by 2.0 has changed. The id is not myDataGrid__ctl2_CheckBox1, but myDataGrid:_ctl2:CheckBox1, but the name attribute remains unchanged. You can guess the purpose of Microsoft's doing this. Just make the id and name consistent. In fact, it should be like this. Maybe this is one of the unreasonable aspects of dotnet1.1.
A small discovery, I hope it helps everyone.