Your strategic advantage starts here

Unblock the ASP.Net Form Submit after PostBack

Unblock the ASP.Net Form Submit after PostBack

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;
});

 

Related Posts
Leave a Reply
Give us a call

Available from 9am to 8pm, Monday to Friday.

Send us a message

Send your message any time you want.

Our usual reply time: 1 Business day
Give us a call

Available from 9am to 8pm, Monday to Friday.

Send us a message

Send your message any time you want.

Our usual reply time: 1 Business day