I am in the process of upgrading a legacy ASP.Net Website (Web Forms) from .NET 3.5 to .NET 4.5. I recently noticed after the upgrade some ASP.Net controls were re-named from ctl00_Content_dropDown1 to ctl00$Content$dropDown1 in the HTML, breaking a lot of the client-side JavaScript.
How can I stop this change from occurring after the upgrade?
docs.Microsoft.com says that moving from .NET 3.5 to .NET 4.0 (or greater) causes this breaking change that changes the way that the
idattribute for elements is generated.In the web.config file, change the
<pages>element, add theclientIDModeattribute to it like this:This should continue making IDs in the way that it did before.
In addition to
AutoID, MSDN lists several other useful options:Visual Studio is supposed to set the
ClientIDModetoAutoIDwhen you upgrade from .NET 3.5 to .NET 4.5, however I don't think it works when you do not have a ASP.Net Web Project (.csproj) and instead all you have is a ASP.NET Website.