简体   繁体   English

ASP.NET:避免使用导航按钮回发时的RequiredFieldValidator

[英]ASP.NET: avoid RequiredFieldValidator on navigate button postback

I have an ASPX page with two RequiredFieldValidator and a button to go to another page. 我有一个带有两个RequiredFieldValidator的ASPX页面和一个转到另一个页面的按钮。 This button must do a postback to know where to go. 此按钮必须进行回发才能知道要去哪里。 This button can be clicked it any time. 可以随时单击此按钮。

The problem is that the RequiredFieldValidators are not disabled and show their message asking for a value. 问题是RequiredFieldValidators未被禁用,并显示要求输入值的消息。

Is there any way to avoid validation when the user click this special button? 当用户单击此特殊按钮时,有什么方法可以避免验证吗?

Thank you! 谢谢!

Set CausesValidation to false on the special button, or put the RequiredFieldValidators in a ValidationGroup with whatever should cause the validation. 在特殊按钮上将CausesValidation设置为false,或将RequiredFieldValidators放在ValidationGroup中,其中包含任何应导致验证的内容。 (The button that should cause validation and the validators should all be in the same validation group) The first option should work and be the quickest. (应该导致验证的按钮和验证器都应该在同一个验证组中)第一个选项应该工作并且是最快的。

的CausesValidation = “假”

You can add a ValidationGroup to the controls. 您可以将ValidationGroup添加到控件。

On the submit button you also add a Validationgroup 在提交按钮上,您还可以添加Validationgroup

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM