Is there a way to disable Event Validation for an entire page?
I have a nested user control which appears on every single page. It contains some validation in the form of ASP.NET validators.
The problem I'm running into is, since it's on every page (in essence it's loca开发者_如何学Goted in my left navigation control), I need to set CausesValidation="false"
on every single button etc..
Is there a way to set CausesValidation="false" at the Page Level?
Page.EnableEventValidation = false;
It is strongly recommended that you do not disable event validation. If you do disable event validation, make sure that no postback could be constructed that could have an unintended effect on your application.
http://msdn.microsoft.com/en-us/library/system.web.ui.page.enableeventvalidation.aspx
Try the Page.EnableEventValidation property:
http://msdn.microsoft.com/en-us/library/system.web.ui.page.enableeventvalidation%28VS.80%29.aspx
Event Validation and the causes validation property of a control are very different things.
I think what you want to do is stop the asp validators in your usercontrol from firing when you are doing something in the main content of your page.
All you need to do is add a ValidationGroup name to the validators and the button which submits the form in your usercontrol.
BTW: Event validation is a bit of .NET magic which stops anything which looks like javascript being entered into a form and submitted to a server.
Turning this off == bad times.
精彩评论