作用:对Textbox或者其他输入框进行比较验证;

属性:ControlToValidate:要验证的控件;

ErrorMessage:错误提示信息;

ControlToCompare:与此相比的控件ID;

Type

类型                                   作用                                                
Integer 整数型
Date 日期
Double 双精度浮点型
String 字符串型
Currency 货币类型

Operator:操作类型

操作类型                          作用                                                  
Equal 相等
NotEqual 不相等
GreaterThan 数据类型验证
GreaterThanEqual 大于
LessThan 大于等于
LessThanEqual 小于
DataTypeCheck 小于等于

原型:

Demo:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="非空验证.aspx.cs" Inherits="验证控件1.非空验证" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<style type="text/css">
.auto-style1 {
position: absolute;
top: 159px;
left: 360px;
z-index: 1;
}
.auto-style2 {
position: absolute;
top: 190px;
left: 360px;
z-index: 1;
bottom: 452px;
width: 81px;
}
.auto-style3 {
position: absolute;
top: 158px;
left: 436px;
z-index: 1;
}
.auto-style4 {
position: absolute;
top: 189px;
left: 435px;
z-index: 1;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div> </div>
<asp:Label ID="Label1" runat="server" CssClass="auto-style1" Text="密码:"></asp:Label>
<asp:Label ID="Label2" runat="server" CssClass="auto-style2" Text="确认密码:"></asp:Label>
<asp:TextBox ID="txtPwd" runat="server" CssClass="auto-style3"></asp:TextBox>
<asp:TextBox ID="txtPwdOk" runat="server" CssClass="auto-style4"></asp:TextBox>
<p>
 </p>
<p>
 </p>
<asp:Button ID="btnLogin" runat="server" OnClick="btnLogin_Click" style="z-index: 1; left: 390px; top: 299px; position: absolute; width: 63px; height: 21px" Text="注册" />
<asp:Button ID="btnSet" runat="server" OnClick="btnSet_Click" style="z-index: 1; left: 559px; top: 299px; position: absolute; width: 64px; height: 21px" Text="重置" />
<asp:Label ID="Label3" runat="server" style="z-index: 1; left: 361px; top: 232px; position: absolute" Text="注册日期:"></asp:Label>
<asp:TextBox ID="txtDate" runat="server" style="z-index: 1; left: 434px; top: 229px; position: absolute; height: 15px"></asp:TextBox>
<asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="txtPwd" ControlToValidate="txtPwdOk" ErrorMessage="*确认密码有误!" ForeColor="Red" style="z-index: 1; left: 598px; top: 192px; position: absolute" Operator="DataTypeCheck"></asp:CompareValidator>
<asp:CompareValidator ID="CompareValidator2" runat="server" ControlToValidate="txtDate" ErrorMessage="*日期格式不正确" ForeColor="Red" Operator="DataTypeCheck" style="z-index: 1; left: 598px; top: 231px; position: absolute" Type="Date"></asp:CompareValidator>
</form>
</body>
</html>

感谢您的宝贵时间···

ASP.NET控件之CompareValidator控件的更多相关文章

  1. ASP.NET CompareValidator 控件在VS2012中出错的问题

    CompareValidator 控件用于将由用户输入到输入控件的值与输入到其他输入控件的值或常数值进行比较. -------如果输入控件为空,则不会调用任何验证函数,并且验证将成功.使用 Requi ...

  2. asp.net控件的Hyperlink控件

    Asp.net控件: Hyperlink控件:Hyperlink控件又称为超链接控件,该控件在功能上跟Html的<a herf=””>控件相似,其显示的模式为超链接的形式. 注意: Hyp ...

  3. 《ASP.NET1200例》ListView 控件与DataPager控件的结合<二>

    ASP.NET使用ListView数据绑定控件和DataPager实现数据分页显示 为什么使用ListView+DataPager的方式实现分页显示? .net提供的诸多数据绑定控件,每一种都有它自己 ...

  4. 《ASP.NET1200例》ListView 控件与DataPager控件的结合<一>

    分页     在前一部分开始时介绍的原 HTML 设计中内含分页和排序,所以根据规范完整实现该网格的任务尚未完成.我们先分页,然后再排序. ListView 控件中的分页通过引入另一个新控件 Data ...

  5. RequiredFieldValidator 控件 CompareValidator 控件

    RequiredFieldValidator 控件 验证关联控件非空 ControlToValidate 属性用来关联被验证控件 ErrorMEssage 触发控件后显示的错误信息 CompareVa ...

  6. 027. asp.net中数据绑定控件之 GridView控件

    GridView控件支持下面的功能: 绑定至数据源控件, 如SqlDataSource 内置排序功能 内置更新和删除功能 内置分页功能 内置行选择功能 可以编程方式访问GridView对象模型以动态设 ...

  7. asp.net 弹出式日历控件 选择日期 Calendar控件

    原文地址:asp.net 弹出式日历控件 选择日期 Calendar控件 作者:逸苡 html代码: <%@ Page Language="C#" CodeFile=&quo ...

  8. ASP.NET关于Login控件使用,LoginView 控件,CreateUserWizard 控件

    原文:ASP.NET关于Login控件使用,LoginView 控件,CreateUserWizard 控件 Login控件它是属于Membership服务的一部分,必须配置Membership提供程 ...

  9. asp.net学习之 数据绑定控件--List数据绑定控件

    原文:asp.net学习之 数据绑定控件--List数据绑定控件 List控件(如 CheckBoxList.DropDownList.ListBox 和 RadioButtonList 类)继承自L ...

随机推荐

  1. DBGrid和DBGridEH

    二.应用实例 Enlib3.0组件包安装成功后 A.定制标题行 1.制作复杂标题行 标题行可设为2行以上高度,并可以为多列创建一个共同的父标题行.为实现这个效果,需在各个列标题属性中以“|”分隔父标题 ...

  2. 分享知识-快乐自己:揭秘HDFS

    揭秘HDFS: 一):大数据(hadoop)初始化环境搭建 二):大数据(hadoop)环境搭建 三):运行wordcount案例 四):揭秘HDFS 五):揭秘MapReduce 六):揭秘HBas ...

  3. pow,sqrt使用时需注意

    使用时注意类型,可见两者皆不可以用int 1.pow 函数声明: double pow (double base , double exponent); float pow (float base , ...

  4. php 数字小写转为大写的函数

    PHP把阿拉伯数字转换成中文,需要定义一个转换的算法: <?php /将数字转换为汉字,比如1210转换为一千二百一十 $num = "842105580";//九位数 fu ...

  5. bzoj 3012: [Usaco2012 Dec]First! Trie+拓扑排序

    题目大意: 给定n个总长不超过m的互不相同的字符串,现在你可以任意指定字符之间的大小关系.问有多少个串可能成为字典序最小的串,并输出这些串.n <= 30,000 , m <= 300,0 ...

  6. js之__proto__原型链

    可参考: http://blog.csdn.net/irelandken/article/details/7297490

  7. Poj 2136 Vertical Histogram(打印垂直直方图)

    一.Description Write a program to read four lines of upper case (i.e., all CAPITAL LETTERS) text inpu ...

  8. js---window对象的三种窗口

    ============================================================================ window对象的三种窗口.html < ...

  9. MAXOS安装FFMPEG

    安装brew 安装方法:命令行输入 /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/ins ...

  10. K-NN回归算法

    from sklearn.datasets import load_iris import numpy as np import matplotlib.pyplot as plt iris = loa ...