Avatar of HLRosenberger
Flag for United States of America

asked on 

cannot access a control

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??


Avatar of undefined
Last Comment

8/22/2022 - Mon