When ASP.NET controls are rendered their ids sometimes change, like if they are in a naming container.
Button1 may actually have an id of
ctl00_ContentMain_Button1 when it is rendered, for example.
I have found that writing a function to parse the dom recursively and find a control that CONTAINS the id that I want is unreliable, so I was looking for a best practice rather than a work-around.
Oh, and I also found this, in case anyone else is having this problem.
Use a custom jQuery selector for asp.net controls:
Answered By – NetHawk
Answer Checked By – Dawn Plyler (BugsFixing Volunteer)