开发者

Is there a way to disable Event Validation for an entire page?

开发者 https://www.devze.com 2022-12-10 15:29 出处:网络
I have a nested user control which appears on every single page.It contains some validation in the form of ASP.NET validators.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号