首页 高清影视 网上日记 致富经 展会 音乐生活 网址导航 在线游戏 网站建设 会员中心 注册 更多功能
您的位置:环球搜宝网 > 生活服务 > 网站服务
更新时间:2012/8/1 8:30:58 收藏
ValidationSummary用法


<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>注册表单验证</title>
</head>
<body style="background-image: url(0267.jpg)">
<h4>注册表单验证实例</h4>
<hr />
    <form id="form1" runat="server">
    <div>
        <table border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td  align="right" >注册账号:
                </td>
                <td colspan="2" style=" color: red; ">
                    <asp:TextBox ID="TextBox1" runat="server" Width="381px"></asp:TextBox>
                    *<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="注册账号不能为空"
                    ControlToValidate="TextBox1" EnableTheming="True" Display="None" EnableViewState="False"></asp:RequiredFieldValidator>
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBox1"
                        ErrorMessage="必须是数字和字母" ValidationExpression="^[A-Za-z0-9]+$" Display="None"></asp:RegularExpressionValidator>
                         
                </td>
                       
            </tr>
            <tr>
                <td   align="right" >
                    密码:
                </td>
              
                <td colspan="2" style=" color: red; ">
                    <asp:TextBox ID="TextBox2" runat="server" TextMode="Password" Width="381px"></asp:TextBox>
                    *<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TextBox2"
                        ErrorMessage="密码不能为空" Display="None"></asp:RequiredFieldValidator>
                    <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="TextBox2"
                        ControlToValidate="TextBox3" ErrorMessage="密码和重复密码必须相同" Display="None"></asp:CompareValidator></td>
            </tr>
            <tr>
                <td   align="right" >重复密码:
                </td>
                <td colspan="2" style=" color: red; ">
                    <asp:TextBox ID="TextBox3" runat="server" TextMode="Password" Width="381px"></asp:TextBox>
                    *<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="TextBox3"
                        ErrorMessage="重复密码不能为空" Display="None"></asp:RequiredFieldValidator></td>
            </tr>
            <tr>
                <td   align="right" style="width: 100px">
                     姓名:
                </td>
                <td colspan="2" style=" color: red; ">
                    <asp:TextBox ID="TextBox4" runat="server" Width="381px"></asp:TextBox>
                    *<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="TextBox4"
                        ErrorMessage="姓名必须填写" Display="None"></asp:RequiredFieldValidator></td>
            </tr>
            <tr>
                <td   align="right" >
                    年龄:
                </td>
                <td colspan="2"  >
                    <asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
                    <asp:RangeValidator ID="RangeValidator1" runat="server" ErrorMessage="年龄超出范围(15-110),请正确输入"
                        MaximumValue="110" MinimumValue="15" ControlToValidate="TextBox5" Type="Integer" Display="None"></asp:RangeValidator></td>
            </tr>
            <tr>
              <td   align="right" >
                  保密邮箱:
              </td>
                  <td style="color: #ff0033">
                      <asp:TextBox ID="TextBox6" runat="server" Width="260px"></asp:TextBox>
                      *<asp:RegularExpressionValidator
                          ID="RegularExpressionValidator2" runat="server" ErrorMessage="请正确输入邮箱" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ControlToValidate="TextBox6" Display="None"></asp:RegularExpressionValidator></td>
            </tr>
            <tr>
              <td colspan="2" align="center">
                  <asp:Button ID="Button1" runat="server" Text="提交" Width="75px" OnClick="Button1_Click" CssClass="Button" />
              </td>
            </tr>
            <tr>
              <td colspan="2">
              <asp:ValidationSummary id="ValidationSummary1" runat="server" HeaderText="错误信息"></asp:ValidationSummary>
              </td>
            </tr>
        </table>
      
    </div>
    </form>
</body>
</html>

分享到:
如果此信息不合适,您也可以自己 发布一条信息 通过我们完成交易!
法律声明:本站只提供信息交流平台,各交易者自己审辨真假,如有损失,本站概不负责。
联络时请说明来自环球搜宝网,以获得更好效果。
人浏览发表评论()
评论内容:
验 证 码: 验证码看不清楚?请点击刷新验证码
匿名发表 
所有评论最新评论
正在加载用户数据... 正在加载店铺数据...
  • 会员价:¥元
  • 联系人:姚海风
  • 联系电话:13675727672
  • QQ:195815482
  • 邮箱:195815482@qq.com
  • 联系地址:杭州市西湖区
  • 发布者IP:115.204.229.70
Published at 2017/6/9 21:26:25, Powered By Buy8866 version buy8866.com 8.8.0(MSSQL)