web第二题注册表单

aspx代码

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

<!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 { width:100%; }
        .auto-style2 { height:21px; }
        .auto-style3 { height:21px;width:93px; }
        .auto-style4 { width:93px; }
        .auto-style5 { height:21px;width:135px; }
        .auto-style6 { width:135px; }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <div>
        <table class="auto-style1">
           <tr>
             <td class="auto-style3" style="text-align: right">用户名:</td>
             <td class="auto-style5">
               <asp:TextBox ID="txtName" runat="server" Width="120px"></asp:TextBox>
             </td>
             <td class="auto-style2">
               <asp:RequiredFieldValidator ID="vfvName" runat="server" ControlToValidate="txtName" Display="Dynamic" ErrorMessage="请输入用户名!" SetFocusOnError="True"></asp:RequiredFieldValidator>
             </td>
            </tr>
           <tr>
             <td class="auto-style3" style="text-align: right">密码:</td>
             <td class="auto-style5">
               <asp:TextBox ID="txtPassword" runat="server" TextMode="Password" Width="120px"></asp:TextBox>
             </td>
             <td class="auto-style2">
               <asp:RequiredFieldValidator ID="rfvPassword" runat="server" ControlToValidate="txtPassword" Display="Dynamic" ErrorMessage="请输入密码!" SetFocusOnError="True"></asp:RequiredFieldValidator>
             </td>
            </tr>
            <tr>
             <td class="auto-style4" style="text-align: right">性别:</td>
             <td class="auto-style6">
                 <asp:RadioButtonList ID="sex" runat="server"  RepeatDirection="Horizontal">
                     <asp:ListItem>男</asp:ListItem>
                     <asp:ListItem>女</asp:ListItem>
                 </asp:RadioButtonList>
             </td>
            </tr>
            <tr>
             <td class="auto-style4" style="text-align: right">电话号码:</td>
             <td class="auto-style6">
               <asp:TextBox ID="txtTelephone" runat="server" Width="120px"></asp:TextBox>
             </td>
             <td>
               <asp:RequiredFieldValidator ID="rfvTelephone" runat="server" ControlToValidate="txtTelephone" Display="Dynamic" ErrorMessage="请输入电话号码!" SetFocusOnError="True"></asp:RequiredFieldValidator>
               <asp:RegularExpressionValidator ID="revTelephone" runat="server" ControlToValidate="txtTelephone" Display="Dynamic" ErrorMessage="电话号码格式应为1xxxxxxxxxx!" ValidationExpression="\d{3}-\d{8}" SetFocusOnError="True"></asp:RegularExpressionValidator>
             </td>
            </tr>
            <tr>
                <td style="text-align:right">
                  <asp:Button ID="BtnSubmit" runat="server" Text="注册" OnClick="BtnSubmit_Click" />
                  <asp:Label ID="lblMsg" runat="server"></asp:Label>
              </td>
            </tr>
        </table>
        </div>
    </form>
</body>
</html>

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

<!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 { width:100%; }
        .auto-style2 { height:21px; }
        .auto-style3 { height:21px;width:93px; }
        .auto-style4 { width:93px; }
        .auto-style5 { height:21px;width:135px; }
        .auto-style6 { width:135px; }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <div>
        <table class="auto-style1">
           <tr>
             <td class="auto-style3" style="text-align: right">用户名:</td>
             <td class="auto-style5">
               <asp:TextBox ID="txtName" runat="server" Width="120px"></asp:TextBox>
             </td>
             <td class="auto-style2">
               <asp:RequiredFieldValidator ID="vfvName" runat="server" ControlToValidate="txtName" Display="Dynamic" ErrorMessage="请输入用户名!" SetFocusOnError="True"></asp:RequiredFieldValidator>
             </td>
            </tr>
           <tr>
             <td class="auto-style3" style="text-align: right">密码:</td>
             <td class="auto-style5">
               <asp:TextBox ID="txtPassword" runat="server" TextMode="Password" Width="120px"></asp:TextBox>
             </td>
             <td class="auto-style2">
               <asp:RequiredFieldValidator ID="rfvPassword" runat="server" ControlToValidate="txtPassword" Display="Dynamic" ErrorMessage="请输入密码!" SetFocusOnError="True"></asp:RequiredFieldValidator>
             </td>
            </tr>
            <tr>
             <td class="auto-style4" style="text-align: right">性别:</td>
             <td class="auto-style6">
                 <asp:RadioButtonList ID="sex" runat="server"  RepeatDirection="Horizontal">
                     <asp:ListItem>男</asp:ListItem>
                     <asp:ListItem>女</asp:ListItem>
                 </asp:RadioButtonList>
             </td>
            </tr>
            <tr>
             <td class="auto-style4" style="text-align: right">电话号码:</td>
             <td class="auto-style6">
               <asp:TextBox ID="txtTelephone" runat="server" Width="120px"></asp:TextBox>
             </td>
             <td>
               <asp:RequiredFieldValidator ID="rfvTelephone" runat="server" ControlToValidate="txtTelephone" Display="Dynamic" ErrorMessage="请输入电话号码!" SetFocusOnError="True"></asp:RequiredFieldValidator>
               <asp:RegularExpressionValidator ID="revTelephone" runat="server" ControlToValidate="txtTelephone" Display="Dynamic" ErrorMessage="电话号码格式应为1xxxxxxxxxx!" ValidationExpression="\d{3}-\d{8}" SetFocusOnError="True"></asp:RegularExpressionValidator>
             </td>
            </tr>
            <tr>
                <td style="text-align:right">
                  <asp:Button ID="BtnSubmit" runat="server" Text="注册" OnClick="BtnSubmit_Click" />
                  <asp:Label ID="lblMsg" runat="server"></asp:Label>
              </td>
            </tr>
        </table>
        </div>
    </form>
</body>
</html>

cs代码

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class two : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void BtnSubmit_Click(object sender, EventArgs e)
    {
        lblMsg.Text = "";
        if(Page.IsValid)
        {
            lblMsg.Text = "验证通过!";
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class two : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void BtnSubmit_Click(object sender, EventArgs e)
    {
        lblMsg.Text = "";
        if(Page.IsValid)
        {
            lblMsg.Text = "验证通过!";
        }
    }
}

  • 22
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值