Re: Framework-generated ID woes

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Darn it. No way to specify the ID prefix? Seems dangerous to modify
this ClientID property (if that's even possible, haven't looked...)

Mark

Bruno Alexandre wrote:
component.ClientID

:-)

like:

document.getElementById( '<%= myLabel.ClientID %>' ).value = 'test';

--

Bruno Alexandre
(a Portuguese in Københanv, Danmark)


<mark.norgate@xxxxxxxxx> escreveu na mensagem
news:1150292921.945833.79700@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi

I have lots of controls on my ASP.NET 2.0 page, some implementing
INamingContainer, others just <asp:button>s and so on.

The eternal lament: I need to interact with these controls on the
client-side, but of course I can't guarantee that the IDs generated by
the Framework will be consistent (like
"ctl00_ContentPlaceHolder_LoadPreviousButton").

Is there a way to tell the Framework what prefix you'd like to use for
your controls' IDs? Or do I have to resort to injecting some JavaScript
containing the ID into the page (which is rather ugly I think). If so,
how do I actually get the fully-qualified name of the control?

Thanks, Mark


.


Quantcast