ASP.NET 2.5 prefixing ctl00 and ASP.NET 4 not prefixing ctl00

In ASP.NET 4.0, they’ve introduced support for cleaner HTML syntax. You can read about it at Scott Gu’s blog. If you want the classic model for Client IDs, you can adjust your web.config:

<configuration>
    <system.web>
        <pages controlRenderingCompatibilityVersion="3.5" />

And that’ll make upgrading your application easier. You can change this per control (and per page) by using the Control.ClientIDMode property, which can also be set in the web config:

<configuration>
    <system.web>
        <pages clientIDMode="AutoID|Predictable|Static|Inherit" />

AutoID renders the controls with the classic ASP.NET 2.0 model.

Leave a Comment