I've created a simple ASP.NET 4.0 application to see how rendered client ids will vary if I change controlRenderingCompatibilityVersion in web.config and ClientIDMode attribute of the control. Now I've set <pages controlRenderingCompatibilityVersion="3.5"/> and <asp:Label runat="server" ID="Message" ClientIDMode="AutoID" /> and expect to find in the generated markup asp.net-3.5-style ClientID (something like id='ctl00_Message'), but I see this <span id="Message">Hello world!</span>.

Why does not ASP.NET render it as a 3.5-style id?

有帮助吗?

解决方案

If the span is on it's own, then there is no reason to change the ID.

It depends if the control is inside another control. If the span above is inside a Repeater, DataList etc, then the Id will change.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top