When you have an ASP control like this:
<asp:TreeView ID="TreeItems" runat="server"></asp:TreeView>
The html that it generates mangles the names. If I want to access the ids of the generated items directly, I can try and figure out what it mangles the names to and look for that ID.
Are the names of the items generated guaranteed to be done in a specific way by whatever standard there is from Microsoft? I'm just afraid of this breaking if they release a new version of .NET that does it in a different way. Is there a way to generate the name mangling myself in code?
It isn't guranteed to be consistent (it's an implementation detail)
Use ClientID instead (which gives you the generated id).
I believe with ASP.NET on .NET 4, you can specify that the IDs be generated a certain way.
See: http://weblogs.asp.net/asptest/archive/2009/01/06/asp-net-4-0-clientid-overview.aspx
Additionally, if you are using jQuery, you can be sure that the nominal ID will be in the client ID, so you could select it with something like:
$("input[id*='TreeItems']")
See: http://api.jquery.com/attribute-contains-selector/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With