Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I have a control:

XML
<asp:TextBox ID="ControlName" runat="server" />


I want to reference it in some Javascript.

ASP.Net mangles the ID into ctl00_ContentPlaceHolder1_ControlName.
To keep things simple I want to refer to it as ControlName in my script: future versions of the page might have the control in a different container which would alter the ID, and I would rather not have to remember to rewrite the script.

Is there any way to instruct ASP.Net, either for this specific control or generally, NOT to mangle the ID?
Posted
Updated 23-Mar-11 6:17am
v2
Comments
Dalek Dave 23-Mar-11 12:17pm    
Edited for Readability.

1 solution

 
Share this answer
 
Comments
Gregory Gadow 23-Mar-11 12:07pm    
That's what I was afraid of. It makes sense to generate a guaranteed unique id when merging pages, but it's a (redacted) nuisance. Unfortunately, none of the solutions mentioned in your link offer anything I can implement. Thanks for the info.
Dalek Dave 23-Mar-11 12:17pm    
Good link John.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900