简体   繁体   English

使用必填字段验证器时如何清除控件?

[英]How do I clear controls when using required field validator?

I have a form with a number of textboxes and dropdownlist .. I have a clear Button which upon clicking is supposed to clear all the fields. 我有一个带有多个文本框和下拉列表的表单。我有一个清晰的按钮,点击后应该清除所有字段。 But since i have required field validators and regular expressions validator on the form I am not able to fire click event unless all validation are satisfied. 但由于我在表单上需要字段验证器和正则表达式验证器,因此除非满足所有验证,否则我无法触发单击事件。

You can use the CausesValidation property 您可以使用CausesValidation属性

<asp:Button ID="BtnClearForm"
                Text="clear form"
                CausesValidation="False"
                OnClick="BtnClearForm_Click"
                runat="server"/>

Another option is to use javascript to clear your inputs . 另一个选择是使用javascript 清除您的输入

将clear按钮的CausesValidation属性设置为false。

try this: 试试这个:

CausesValidation of clear button must be false . 清除按钮的CausesValidation必须为false

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

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