简体   繁体   English

选择取消按钮时如何关闭必填字段验证器

[英]How to turn required field validator off when selecting cancel button

I have a problem where my page has a required field validator, but I also want to use a 'cancel' button which will take the user back to the menu page using response.redirect("default.aspx"); 我的页面上有一个必需的字段验证器,但我也想使用一个“取消”按钮,该按钮将使用response.redirect(“ default.aspx”)将用户带回到菜单页面。

Problem is the field validator keeps firing when you click the cancel button. 问题是单击“取消”按钮时,字段验证器会不断触发。 How do you turn this off so the user can return to the menu page? 您如何关闭此功能,以便用户可以返回菜单页面?

只需将CausesValidation="false"添加到您的按钮定义中,它将不会引发任何验证器:

<asp:Button ID="btnCancel" runat="server" Text="Cancel" CausesValidation="false" />

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

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