JavaScript and User controls
Hi,
I'm confused about how ASP.NET assigns DOM level IDs for items inside user controls.
For example if I have a label declared as follows:
<asp:Label ID="lblAddress" runat="server">Address:</asp:Label>
I would expect that my ID would come up in the browser as lblAddress. That way I could execute Javascript against it. But it turns out that ASP.NET prefixes different stuff to the ID, depending on where the control is, i.e. is it in a page, a panel within a page, on a master, in a user control etc.
What I've been doing is just finding it in the control in the source and then copying the ID and pasting it into my JavaScript. Very clunky. It would be much better to either:
1) be able to find it in the javascript, using some method similar to getElementById
2) Know exactly how ASP.NET is going to Prefix my IDs, based on where they are.
The former method would be more desirable, but the latter is probably more realistic.
Thanks for your help.
Aaron
|