I had an ASP.Net form whereby when a dropdown list entry was changed, it would cause a post back and different form elements would show or hide depending upon the value.  What I noticed is that when a user had attempted to submit the form before and validation failed, then the dropdown list change would not cause a post back.  This was not the desired behaviour so I looked at ways of either resetting page validation or ignoring it.

Attempt 1:  Set CausesValidation to false on the Dropdown list element.  This didn’t work.  The form still did not post back.

Attempt 2:  Disable all Validators

The second attempt I tried was to disable all page validators by calling the following function:

function DisableValidation() {
    if (Page_Validators.length > 0) {
        for (i = 0; i < Page_Validators.length; i++) {
            ValidatorEnable(Page_Validators[i], false);
        }
    }
}

$("#servicetypeDDL").change(function () {
   DisableValidation();
});

It appeared to disable the validators and the validation messages were reset to blank, however the page still didn’t post back.

Attempt 3:

To unblock the ASP.Net form submit after PostBack I ended up having to implement the configuration below:

$("#servicetypeDDL").change(function () {
   DisableValidation();
   Page_BlockSubmit = false;
});

 

Unblock the ASP.Net Form Submit after PostBack
Comments have now been disabled. If you have a question to ask about this post please ask the community!