asp.net中的自定义验证器 [英] custom validator in asp.net

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

问题描述

hi ,,
如果我想使用自定义验证器比较两个文本框,我确切不知道的代码是什么,请尽快告诉我代码
例如,我在一个文本框中输入密码,而另一个是重新输入密码,我想对两个文本框都进行比较,请告诉我代码..........



在此先感谢..........

hi ,,
if i want to compare two textboxes by using custom validator,what is the code i dont know exactly please tell me the code as soon as possible
for example am taking password in one textbox and other is retype password,i want comapre both the textboxes please tell me code..........



Thanks In Advance..........

推荐答案

为什么不使用CompareValidator?


<table border="0" bgcolor="#b0c4de">
   <tr valign="top">
     <td colspan="4"><h4>Compare two values</h4></td>
   </tr>
   <tr valign="top">
     <td><asp:TextBox id="txt1" runat="server" /></td>
     <td> = </td>
     <td><asp:TextBox id="txt2" runat="server" /></td>
     <td><asp:Button Text="Validate" runat="server" /></td>
   </tr>
</table>
<br />
<asp:CompareValidator

id="compval"

Display="dynamic"

ControlToValidate="txt1"

ControlToCompare="txt2"

ForeColor="red"

BackColor="yellow"

Type="String"

EnableClientScript="false"

Text="Validation Failed!"

runat="server" />


您可以使用比较验证器,并将controltocompare设置为密码文本框的ID,将controltovalidate设置为确认密码文本框的ID.运算符应相等或类似.
you can use compare validator and set the controltocompare as the id of the password textbox and controltovalidate as the id of the confirm password textbox. operator should be equal or something similar.


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

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