In my asp page I used 2 asp panel controls.The second panel was not visible as the style property of it was set to hidden.Panel 2 is displayed through javascript code which change the style property to visible according to the value of a checkbox in panel 1. On postback although the panel 2 is hidden its asp validations are pop up and the postback is not happening.I tried to disable the server controls via javascript,but its not working.
Can someone help me in this?
function DisablePanel() {
var div_to_disable =document.getElementById('<%=Panel1.ClientID%>').getElementsByTagName("input");
var children = div_to_disable;
for (var i = 0; i < children.length; i++) {
children[i].disabled = true;
};
}
function EnablePanel() {
var div_to_disable = document.getElementById('<%=Panel1.ClientID %>').getElementsByTagName("input");
var children = div_to_disable; //.childNodes;
for (var i = 0; i < children.length; i++) {
children[i].disabled = false;
};
}
function ShowPanel2() {
var panel = document.getElementById('<%=Panel2.ClientID %>');
if (panel.style.visibility == 'hidden') {
EnablePanel();
panel.style.visibility = 'visible';
}
else { DisablePanel();
panel.style.visibility = 'hidden';
}