I wrote An ASPX page, put a gridview, add a template column in The gridview, put a linkbutton in it, and display data
The problem is
1) on the Local Development Machine
The ID and name of the linkbutton are
ID: gridview1_ Ctl02_ Lbtnsel
Name: gridview1$ Ctl02 $Lbtnsel
2) Deploy the server
The ID and name of the linkbutton are
ID: gridview1_ Ctl2_ Lbtnsel
Name: gridview1$ _ Ctl2$ Lbtnsel
After comparison, the IDs and names generated on the local machine are normal, clientid is separated by an underscore (_), and uniqueid is separated by a dollar.Ctl02The second row of the gridview.
The IDS and names generated on the server are a little different. Although clientid is still separated by an underscore (_), uniqueid is separated by a dollar, however, the representation of the second row of the gridview is significantly different._ Ctl2
The server changes 02 to 2 and starts with an underscore.
Why? This problem causes some JS Code on the page to fail to run normally, because even the ID and name rules have changed and the cause is not found. Thank you for your advice.
Runtime Environment. Net version 2.0.50727, win2003
Solution:
In web. config, remove<XhtmlconformanceMode ="Legacy"/>Attribute
See http://www.microsoft.com/china/msdn/library/webservices/asp.net/ASPNETusStan.mspx
To meet everyone's requirements, Microsoft has created a new configuration option named xhtmlconformance. You can set this option in the configuration file of the web site. The new configuration options enable you to specify the XHTML consistency level for Web pages. Its content is as follows.
<Configuration>
<System. Web>
<Xhtmlconformance
Mode = "Transitional"/>
</System. Web>
</Configuration>
By default, xhtmlconformance is set to transitional. However, you can set this option to strict or legacy.
If you set the xhtmlconformance option to strict, the standard ASP. Net Control will no longer render certain attributes. For example, the ASP. NET <form> control no longer presents the name attribute. Unless the ASP. NET page contains (non-compliant) client scripts, no changes are noticed when switching from transitional mode to strict mode.
If you set the xhtmlconformance option to legacy, the ASP. NET Framework restores some elements and attributes (but not all) to ASP. NET 1.1 rendering. In this case, the ASP. NET Framework will present content that is not compatible with any XHTML standard and the page will no longer pass the XHTML standard verification. For example, in legacy mode, when a <br> tag is displayed, the expected XHTML end slash (<br/>) is not displayed ). It makes sense to set xhtmlconformance to legacy only when you encounter problems when migrating existing ASP. NET 1.1 applications to ASP. NET 2.0.