I'm having some problems with implementing javascript controls in my asp.net page. I would like to have a set of variables get their values based on some asp button controls. Then I manipulate those buttons based on how they are clicked. I'm having some issues though:
- Any global variables I define and give a value to are coming back as null
- I can't run a onload event, because all my variables come back as null.
- I can't use the asp.net tags of visible="false" because then the javascript can't show the control for some reason.
- the javascript style.visibility="visible" doesn't really work as you can still see where the button would be - it just isn't visible.
So here is my code. The TL,DR is I'd like to run some behavior to conditionally show/hide buttons via js on load, and then hide/show buttons on different button clicks. I know it is a scope issue, as the global variables return "null" when I test them, but I don't know a good workaround for that and the onload issue. Thanks!
var btnEdit = document.getElementById("<%= cmdEdit.ClientID %>");
var btnSave = document.getElementById("<%= cmdSave.ClientID %>");
var btnCanvel = document.getElementById("<%= cmdCancel.ClientID %>");
var btnConfirm = document.getElementById("<%= cmdConfirm.ClientID %>");
function HideEdit(){
$(btnEdit).hide();
$(btnSave).show();
$(btnCancel).show();
$(btnConfirm).hide();
document.getElementById("<%= pnlWhy.ClientID %>").style.visibility = "visible";
document.getElementById("<%= pnlRequest.ClientID %>").style.visibility = "visible";
}
function testme() {
alert(btnEdit)
}
function loadpage(newwine){
if (newwine==true){
$(btnEdit).hide();
$(btnSave).show();
$(btnCancel).show();
}
else{
$(btnEdit).show();
}
$(btnConfirm).hide();
}