如何禁用Asp.net中特定按钮的验证 [英] How to Disable Validation to a particular Button in Asp.net
本文介绍了如何禁用Asp.net中特定按钮的验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有必填字段验证器的 TextBox 并且有两个按钮
1.Save
2。关闭
当我点击保存按钮时,它正在验证TextBox为空或不是哪个是我的要求。
但是当我点击关闭按钮时,它也会验证TextBox,这不是我的要求。
如何禁用关闭按钮的验证。
I have a TextBox with Required Field Validator and having two buttons
1.Save
2.Close
When i click on save button it is validating the TextBox Empty or Not which is my Requirement.
But When i click on Close button also it is validating the TextBox which is not my Requirement.
How to disable validation for Close Button.
推荐答案
您需要为关闭按钮
<asp:button id="btnCancel" runat="server" text="Cancel" causesvalidation="false" />
签出 -
如何:禁用ASP.NET服务器控件的验证 [ ^ ]
ASP.NET验证控件:如何禁用它 [ ^ ]
Check out -
How to: Disable Validation for ASP.NET Server Controls[^]
ASP.NET Validation Controls: How to Disable It[^]
<asp:textbox id="txtNewName" runat="server" xmlns:asp="#unknown" />
<asp:requiredfieldvalidator id="vldtxtNewName" runat="server" controltovalidate="txtNewName" xmlns:asp="#unknown"> ValidationGroup="NewDepartmentValidationGroup"
ErrorMessage="Required Field" />
<asp:button id="save" runat="server" text="Create"
ValidationGroup="NewDepartmentValidationGroup" OnClick="cmdCreate_Click" causesvalidation="true" /></asp:button>
<asp:button id="close" runat="server" text="Create"
OnClick="cmdCreate_Click" /></asp:button></asp:requiredfieldvalidator>
设置保存按钮的验证组属性
set the validation group property for save button
这篇关于如何禁用Asp.net中特定按钮的验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文