Question about Client IDs

Posted by George on Stack Overflow See other posts from Stack Overflow or by George
Published on 2010-04-25T00:44:43Z Indexed on 2010/04/25 0:53 UTC
Read the original article Hit count: 274

Filed under:
|

I have a user control that is emmitting javascript using the ClientId function. For example:

Out &= "ValidatorHookupControlID(" & Quote & ddlMonth.ClientID & Quote & "), document.all(" & Quote & CustomValidator1.ClientID & Quote & "));" & vbCrLf

It appears to me that the ClientID function DOES not return the ultimate ID that is sent to the browser. Instead, the ClientID function only appears to be aware of its current parent control, which in this case is a the User Control and so the ID that is returned is the ID "dtmPassportExpirationDate_ddlMonth"

When in fact the usercontrol is included in a master page and the ultimate ID that is used is:

"ctl00_phPageContent_dtmPassportExpirationDate_ddlMonth"

I may be nuts, but that's what it appears to be doing. I expect that the ClientID function would return the ultimate ID used in the HTML.

Am I missing something?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about JavaScript