HLRosenberger
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(btn)
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.Cl ientID %>");
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??
Thanks.
var category = document.getElementById("<
However, this does not work for my SAVE button.
var btn= document.getElementById("<
alert(btn)
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_
So, I did this:
var btn= document.getElementById("<
But this fails at runtime with the following error:
'ctl00_PageContent_btnSave
So, if the declared ID is different than the generated ID, how does one reference this control via Javascript??
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I think it should work:
Your method is right to get reference of a control with server tags like:
var btn= document.getElementById("< %= btnSave.ClientID %>");
As it doesn't work, try this...
var btn = document.getElementById("c tl00_PageC ontent_btn Save");
alert(btn);
Your method is right to get reference of a control with server tags like:
var btn= document.getElementById("<
As it doesn't work, try this...
var btn = document.getElementById("c
alert(btn);
Try this:
btn.disabled="disabled";
or
btn.disabled="true";
btn.disabled="disabled";
or
btn.disabled="true";
ASKER
I never got this to work.
Technically I answered your question correctly, as you confirmed in your response (ID 35771380). You then asked a new question which was not correctly answered. Therefore, unfortunately, I will be objecting.
This question is answered, please stop request for attention
All,
Following an 'Objection' by Tomarse111 (at https://www.experts-exchange.com/questions/27052278/25-May-11-11-Automated-Request-for-Review-Objection-to-Delete-Q-27041077.html) to the intended closure of this question, it has been reviewed by at least one Moderator and is being closed as recommended by the Expert.
At this point I am going to re-start the auto-close procedure.
Thank you,
_alias99
Community Support Moderator
Following an 'Objection' by Tomarse111 (at https://www.experts-exchange.com/questions/27052278/25-May-11-11-Automated-Request-for-Review-Objection-to-Delete-Q-27041077.html) to the intended closure of this question, it has been reviewed by at least one Moderator and is being closed as recommended by the Expert.
At this point I am going to re-start the auto-close procedure.
Thank you,
_alias99
Community Support Moderator
ASKER
Now, I want to disable this button. But this does not seem to work.
btn.disabled = true;
Any idea why, or what I'm doing wrong?