troubleshooting Question

cannot access a control

Avatar of HLRosenberger
HLRosenbergerFlag for United States of America asked on
8 Comments1 Solution240 ViewsLast Modified:
I am successfully referencing other controls on my page like this:

var category = document.getElementById("<%= lstCategory.ClientID %>");

However, this does not work for my SAVE button.  

var btn= document.getElementById("<%= btnSave.ClientID %>");

Alert displays "null".

So, I displayed the source after the page is rendered.  And this is the ID for the SAVE button:  ctl00_PageContent_btnSave__Button

So, I did this:

var btn= document.getElementById("<%= ctl00_PageContent_btnSave__Button.ClientID %>");

But this fails at runtime with the following error:

'ctl00_PageContent_btnSave__Button' is not declared.

So, if the declared ID is different than the generated ID, how does one reference this control via Javascript??


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros