RequiredFieldValidator控件:

·RequiredFieldValidator控件也被称之为必填验证控件,顾名思义,也就是与RequiredFieldValidator控件关联的控件的值在默认设置下必须填写。可以通过更改此空间的InitialValue属性来要求所验证的控件的值不能与InitialValue属性值一致。

例子:

 <body>
<form id="form1" runat="server">
<div>
用户名:<asp:TextBox ID ="user" runat ="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate ="user" ErrorMessage="所填写内容不能为空!"></asp:RequiredFieldValidator> 地址:<asp:DropDownList ID ="drp" runat ="server">
<asp:ListItem Selected ="True">请选择…</asp:ListItem>
<asp:ListItem>北京</asp:ListItem>
<asp:ListItem>上海</asp:ListItem>
<asp:ListItem>广州</asp:ListItem>
<asp:ListItem>深圳</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" ControlToValidate ="drp" InitialValue ="请选择…" runat="server" ErrorMessage="所选择内容不能为空!"></asp:RequiredFieldValidator> <asp:Button ID="Button1" runat="server" Text="提交" /><input id="Reset1" type="reset" value="清空" />
</div>
</form>
</body>

RequiredFieldValidator控件--必填验证控件的更多相关文章

  1. ASP.NET中Textbox后的必填验证控件RequiredFieldValidator的使用方法。

    制作效果如下: 实现方法: 1. 拖动RequiredFieldValidator控件到相应的textbox后位置,点击属性面板,输入ErroMessage相应信息,更改ForeColor为红色 设置 ...

  2. WPF验证之——必填验证

    要事先必填验证,首先要重写ValidationRule类的Validate方法,然后在Binding中指定对应的ValidationRule. 第一步:重写ValidationRule的Validat ...

  3. js页面字段的必填验证方法

    https://blog.csdn.net/fn_2015/article/details/73498462 <script type="text/javascript" s ...

  4. kendo upload必填验证

    @using Kendo.Mvc.UI @using StudentManage.Common.Helper @model StudentManage.Models.Home.ImportDataFr ...

  5. Layui 必填验证

    lay-verify="required"

  6. NET中验证控件表达式汇总

    ASP.NET为开发人员提供了一整套完整的服务器控件来验证用户输入的信息是否有效.这些控件如下: 1.RequiredFieldValidator:验证一个必填字段,如果这个字段没填,那么,将不能提交 ...

  7. C#验证控件使用方法及常用正则表达式例析(转)

    ASP.NET为开发人员提供了一整套完整的服务器控件来验证用户输入的信息是否有效.这些控件如下: 1.RequiredFieldValidator:验证一个必填字段,如果这个字段没填,那么,将不能提交 ...

  8. ASP.Net 验证控件 RequiredFieldValidator

    使用 ASP.NET 验证控件可在网页上检查用户输入.有用于各种不同类型验证的控件,例如范围检查或模式匹配验证控件.每个验证控件都引用网页上其他位置的输入控件(服务器控件).当处理用户输入时(例如,当 ...

  9. C# 验证控件的使用RequiredFieldValidator&CompareValidator

    使用验证控件可以向服务器提交表单数据时验证表单内容,下面以RequiredFieldValidator和CompareValidator为例说明验证控件的用法 RequiredFieldValidat ...

随机推荐

  1. vs2013 linq to mysql

    安装文件 1.下载安装文件 2.创建项目 3.创建mysql数据连接 4.新建ADO.NET数据模型 项目实现代码 using (WorkerContainer db = new WorkerCont ...

  2. 开源html5_kiwijs_helloworld

    本次须要的下载文件已经共享出来 网盘地址 由于我使用的是黑苹果系统, window我就无视了. 开发工具使用 网盘里的 dmg :Sublime Text 打开开发工具后在helloworld中找到 ...

  3. Leetcode 动态规划 Unique Paths

    本文为senlie原创.转载请保留此地址:http://blog.csdn.net/zhengsenlie Unique Paths Total Accepted: 17915 Total Submi ...

  4. FZU Problem 2169 shadow

    http://acm.fzu.edu.cn/problem.php?pid=2169 题目大意: S王国有N个城市,有N-1条道路.王都为编号1的城市.叛军驻扎在很多城市.除了王都外有K个城市有军队, ...

  5. 在Windows Server 2008 R2 中架设 SMTP 服务器

    安装SMTP服务器 Step 1 在功能里面勾选SMTP 服务器,一路下一步完成安装 Step 2 在IIS6的SMTP属性里面的访问标签点击连接,然后设置本机可访问. (其实可以不用设置) Step ...

  6. Informatica 9.5.1 安装配置

    Informatica  结构 1个或多个资源库(Respository) PowerCenter数据整合引擎是基于元数据驱动的,提供了基于数据驱动的元数据知识库(Repository),该元数据知识 ...

  7. 进度记录 和 安装imagick时Cannot locate header file MagickWand.h错误的解决

    修改php.ini文件,已使php支持扩展的功能 [root@localhost imagick-2.2.2]# ./configure --with-php-config=/usr/local/ph ...

  8. python2.7_2.2_在套接字服务器上使用ForkingMixIn

    Linux系统下才能用本程序.因为有Frok新的进程.... 代码如下: # -*- coding: utf-8 -*- import os import socket import threadin ...

  9. django template出错

    解决方法一: 先导入settings >>> from django.conf import settings >>> settings.configure() & ...

  10. Mac上使用Visual Studio Code开发/调试.NET Core代码

    Mac上使用Visual Studio Code开发/调试.NET Core代码 .Net Core 1.0终于发布了,Core的一大卖点就是跨平台.这个跨平台不只是跨平台运行,而且可以跨平台开发.今 ...