I have an asp.net page with multiple validation summaries setup with ShowMessageBox="True"
and several validators. I have run into a situation where when validation fails the validation summary displays correctly but then the next click that would normally trigger a postback of the page does not trigger a postback. So the steps look like this:
What could cause this behavior?
EDIT: The validation was being done in the following manner. In the asp page:
<asp:Button runat="server" id="btn" onClientClick="return DoValidation();" />
In the javascript:
function DoValidation() {
if (!Page_ClientValidate('group1'))
return false;
if (!Page_ClientValidate('group2'))
return false;
return true;
}
Use the return value of the function to stop the execution of a form in JavaScript. False would return if the form fails to submit.
Form validation is a “technical process where a web-form checks if the information provided by a user is correct.” The form will either alert the user that they messed up and need to fix something to proceed, or the form will be validated and the user will be able to continue with their registration process.
After working on this and making careful use of the debugger I finally found out that when you do validation the way described in the edit to the question a boolean is set on failure that blocks the next PostBack of the page from going through. I believe this is done when validation is being done automatically instead of explicitly as I'm doing here. Changing the javascript described above to look like this:
function DoValidation() {
if (!Page_ClientValidate('group1')) {
Page_BlockSubmit = false;
return false;
}
if (!Page_ClientValidate('group2')) {
Page_BlockSubmit = false;
return false;
}
return true;
}
Causes the problem to go away. Hopefully this will help the next person who makes the same mistake I did.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With