asp.net web application - server side canceling Submit PostBackUrl if not(!) Page.IsValid
Posted
by
Brent
on Stack Overflow
See other posts from Stack Overflow
or by Brent
Published on 2012-10-31T04:58:01Z
Indexed on
2012/10/31
5:00 UTC
Read the original article
Hit count: 114
ASP.NET
|validation-controls
Thanks for any help
I have a web application, and the submit uses the PostBackUrl to display data if the form is valid.
I need to use different (server side) validation groups, depending on what radiobutton is selected. That is, manually call
Page.Validate('ValidationGroupA').
The validation itself is working fine, in terms of Page.IsValid correctly assigned true or false.
however, if the page is not valid, the page redirects to the page specified by PostBackUrl on the submit button, where the page is found not to be valid, and the client redirected back with:
if (!PreviousPage.IsValid){Response.Redirect("DataEntryPage.aspx");})
However, by getting to here and back again, all form data is lost, and the relevant validation controls and summaries are not displayed.
is there an equivalent of javascripts evt.preventDefault() or some other way, once it is detected validation has failed after a manual call to Page.Validate to post the form back with appropriate validation errors displayed? Thank you.
© Stack Overflow or respective owner