Saturday, March 24, 2012

Validation triggers when trying to navigate away from DetailsView in Insert mode

I have a detailsview with Insert as the default mode. I just set up some RequiredValidators and CustomValidators, which work great.

But if didn't really intend to enter a new record, and instead want to just navigate back to another page (via some nav buttons in my MasterPage), I get validation errors, and can't leave the page.

Looks like it is the RequiredValidators (that generate client-side javascript) that are causing the problem, and not the CustomValidators (which are server-side). Should I just turn "EnableClientScript" to False?

I think you need to addCausesValidation=false to your nav buttons, which will stop the validation running when you click your nav buttons

e.g.

<asp:buttonid="Button1"runat="server"causesvalidation="False"text="Button"/>


Thanks kevanbulmer, worked great!

No comments:

Post a Comment