asp.net验证控件 [英] asp.net validation controls

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

问题描述

您好,



我有一个控件(假设文本框)。如何用2个不同的按钮验证这个控件。



表示为2个按钮放置一个必需的字段验证器(这2个按钮有不同的validationGroup)



我该怎么办?





谢谢和问候

Srishti

Hello,

I have one control (Suppose Textbox). how can i validate this control with 2 different button.

means putting a required field validater for 2 button (those 2 button have a different validationGroup)

How Can i do ?


Thanks & Regards
Srishti

推荐答案

您需要将两个 RequiredFieldValidator 与相应的 ValidationGroup 放在一起。试试这样:

You need to put two RequiredFieldValidator with corresponding ValidationGroup. Try like this:
<asp:textbox id="txt" runat="server"></asp:textbox>
<asp:requiredfieldvalidator runat="server" id="rfv1" controltovalidate="txt" validationgroup="VG1" errormessage="Validation Faild with button 1"></asp:requiredfieldvalidator>
<asp:requiredfieldvalidator runat="server" id="rfv2" controltovalidate="txt" validationgroup="VG2" errormessage="Validation Faild with button 2"></asp:requiredfieldvalidator>
<asp:button id="btn1" runat="server" text="Button 1" validationgroup="VG1" />
<asp:button id="btn2" runat="server" text="Button 2" validationgroup="VG2"/>







--Amit




--Amit


尝试使用方法Validate(string GroupName)在服务器端使用验证;



http://msdn.microsoft.com/en-us/library/0ke7bxeh.aspx [ ^ ]
Try to use the validation on the server side using the method Validate(string GroupName);

http://msdn.microsoft.com/en-us/library/0ke7bxeh.aspx[^]


这篇关于asp.net验证控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆