ASP.NET INamingContainer – Optional prefixes

Does ASP.NET always apply the “ct100$…” prefixes to element IDs, or in some cases does it optimize this away if the element is guaranteed unique anyways.

Recently I have seen builds differing in the ID prefixes being applied, one having the prefixes and one not but both deriving from the same source.

Can anyone provide any more detail this, and on the workings of INamingContainers and ID generation?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

The new ASP.NET 4 ClientIDMode property affects the client-side ID rendered. Setting the naming container control to Predictive is meant to cut down on this… Static takes the exact ID and renders to the client, which you have to be careful to ensure uniqueness.

When you use a naming container (a master page is also a naming container), it appends this longer ID to ensure uniqueness; with .NET 4, they thought a little more about this and added features like Predictive and Static to cut down on the lengths of the IDs.

HTH.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x