本文介绍了如何在asp.net中禁用验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法解决asp.net中的问题.
我有一个具有四个按钮的Web应用程序,这些应用程序链接到一个Sql Server数据库,可以在其中添加,获取,更新,删除客户端.我已将所有文本框(ID,名字,姓氏,电子邮件,确认电子邮件)上的添加"按钮和更新"按钮的CausesValidation设置为true.但是,每次我检索一个客户端并尝试更新某些字段时,确认电子邮件验证都会出现RequiredFieldValidator错误需要确认电子邮件!".我的确认电子邮件包含两个验证,一个RequiredFieldValidator和一个CompareValidator.
如何禁用只弹出更新"按钮的"RequiredFieldValidator"错误?
我的数据库由ID,FirstName,LastName,Email组成.感谢

Hi, I''m having trouble solving a problem in asp.net.
I have a web application that have four buttons which is link to a Sql server database where I can Add, Get, Update, Delete clients. I have set CausesValidation to true for the Add button and the Update button on all textboxes (ID, FirstName, LastName, Email, Confirm Email). However, each time I retrieve a client and try to update some of the fields, the confirm email validation comes up with the RequiredFieldValidator error "Confirmation email required!". My Confirm Email consist of two validation, a RequiredFieldValidator and a CompareValidator.
How can I disable this RequiredFieldValidator error from popping up for the Update button only?
My database consist of ID, FirstName, LastName, Email. Thanks

推荐答案


<asp:TextBox id="Email" runat="server" ... />
<asp:RequiredFieldValidator runat="server" ControlToValidate="Email" ValidationGroup="Add" ... />
<asp:RequiredFieldValidator runat="server" ControlToValidate="Email" ValidationGroup="Update" ... />

<asp:TextBox id="ConfirmEmail" runat="server" ... />
<asp:RequiredFieldValidator runat="server" ControlToValidate="ConfirmEmail" ValidationGroup="Add" ... />
<%-- NB: Not required for the "Update" group --%>

<asp:Button runat="server" Text="Add" ValidationGroup="Add" ... />
<asp:Button runat="server" Text="Update" ValidationGroup="Update" ... />


这篇关于如何在asp.net中禁用验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 05:59