Framework-generated ID woes

  • Thread starter Thread starter mark.norgate
  • Start date Start date
M

mark.norgate

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
 
component.ClientID

:-)

like:

document.getElementById( '<%= myLabel.ClientID %>' ).value = 'test';
 
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
 
with

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

you are not modifing anything!!! just READING the ClientID for the specified
tag.
in the page the code above will render as:

document.getElementById( 'ctl00_mainCHolder_myLabel' ).value = 'test';

if you have the Label in a container called mainCHolder, imagine if you have
the label inside a container and a wizard component...

all you need to worry is to mension myLabel.ClientID

ClientID as u can see is ReadOnly.... you can't alter nothing, we just need
to read it!

I really don't know where do you get the idea for change it!

--

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


<[email protected]> escreveu na mensagem
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
 
Back
Top