0

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';
} 
Arun Babu A
  • 72
  • 10

1 Answers1

0

These posts might help you; Basically you have to just call ASP.NET inbuilt JS function " ValidatorEnable" after the disable method call

Enable/disable asp.net validator controls within a specific "ValidationGroup" with jQuery?

http://geekswithblogs.net/jonasb/archive/2006/08/11/87708.aspx

Community
  • 1
  • 1
Guru Kara
  • 6,272
  • 3
  • 39
  • 50
  • Will it mean that disabling all controls in panel will not disable asp validation controls in the same panel and we have to explicitily disable it? – Arun Babu A Feb 25 '12 at 09:43