c# asp.net 用户注册流程图(7)

在asp.net中有两种容器控件,其中包括panel和placeholder控件。
使用panel控件可以对控件进行分组。一帮助组织web窗体也的内容,将控件组织在面板中,可提供有关在运行时控件应如何分页显示的信息。这里也就是我们所说的在一个页面中通过 “提交”或“下一步”按钮来显示不同的虚假页面,即通过隐藏可以实现,还有panel的外观属性,来设置panel的外观特性。
简单的用户注册流程图:
html代码:

InBlock.gif<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits=" 容器控件._Default" %>
InBlock.gif
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
InBlock.gif
<html xmlns="http://www.w3.org/1999/xhtml" >
InBlock.gif<head runat="server">
InBlock.gif        <title>用户注册流程图</title>
InBlock.gif        <style type="text/css">
InBlock.gif                .style1
InBlock.gif                {
InBlock.gif                        text-align: center;
InBlock.gif                }
InBlock.gif        </style>
InBlock.gif</head>
InBlock.gif<body>
InBlock.gif        <form id="form1" runat="server">
InBlock.gif        <div>
InBlock.gif
InBlock.gif                <asp:Panel ID="Panel1" runat="server" BorderStyle="Groove" Height="333px"
InBlock.gif                        style="text-align: center" Width="909px"><h1> 用户注册</h1>
InBlock.gif                     <table style="height: 218px">
InBlock.gif<tr id="Tr1" runat="server">
InBlock.gif<td>用户名:</td>
InBlock.gif<td><asp:TextBox runat="server" ID="username"></asp:TextBox></td>
InBlock.gif<td>
InBlock.gif                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
InBlock.gif                                ControlToValidate="username" Display="Dynamic" ErrorMessage="请正确输入用户名"></asp:RequiredFieldValidator><! 对用户输入的信息进行非空验证,并为动态显示,如验证不通过弹出”请输入用户名“>
InBlock.gif                </td>
InBlock.gif</tr>
InBlock.gif<tr>
InBlock.gif<td>密码:</td>
InBlock.gif<td><asp:TextBox runat="server" ID="password1" TextMode="Password"></asp:TextBox> </td>
InBlock.gif<td>
InBlock.gif                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
InBlock.gif                                ControlToValidate="password1" Display="Dynamic" ErrorMessage="请输入密码!"></asp:RequiredFieldValidator><! 对密码进行非空验证,并为动态显示,错误时提示:请输入密码>
InBlock.gif                                                </td>
InBlock.gif</tr>
InBlock.gif<tr>
InBlock.gif<td>密码确认:</td>
InBlock.gif<td><asp:TextBox runat="server" ID="password2" TextMode="Password"></asp:TextBox></td>
InBlock.gif<td>
InBlock.gif                <asp:CompareValidator ID="CompareValidator1" runat="server"
InBlock.gif                                ControlToCompare="password1" ControlToValidate="password2" Display="Dynamic"
InBlock.gif                                ErrorMessage="请确认密码正确性"></asp:CompareValidator><!这里的controltocompare是对第一次输入的密码进行比较,测试十分保持一致>
InBlock.gif                                                </td>
InBlock.gif</tr>
InBlock.gif<tr>
InBlock.gif<td>性别:</td>
InBlock.gif<td>
InBlock.gif<asp:RadioButton Text="男" ID="rd1" runat="server" GroupName="1" /><!groupname必须相同>
InBlock.gif<asp:RadioButton Text="女" ID="rd2" runat="server" GroupName="1" />
InBlock.gif</td>
InBlock.gif<td></td>
InBlock.gif</tr>
InBlock.gif<tr>
InBlock.gif<td>联系电话:</td>
InBlock.gif<td><asp:TextBox runat="server" ID="telephone"></asp:TextBox>< /td><!正则表达式偶还没学>
InBlock.gif<td>
InBlock.gif        <asp:RangeValidator ID="RangeValidator1" runat="server" ErrorMessage="请输入电话号码"
InBlock.gif                MaximumValue="199999999999" MinimumValue="0"
InBlock.gif                ControlToValidate="telephone"></asp:RangeValidator><! 比较粗糙的定义范围,最小值为0.,最大值为19999999999>
InBlock.gif        </td>
InBlock.gif</tr>
InBlock.gif<tr>
InBlock.gif<td>兴趣爱好:</td>
InBlock.gif<td>
InBlock.gif<asp:CheckBox runat="server" ID="cb1" Text="篮球" />
InBlock.gif<asp:CheckBox runat="server" ID="cb2" Text="足球" />
InBlock.gif<asp:CheckBox runat="server" ID="cb3" Text="排球" />
InBlock.gif<asp:CheckBox runat="server" ID="cb4" Text="读书" />
InBlock.gif</td>
InBlock.gif<td></td>
InBlock.gif</tr>
InBlock.gif<tr>
InBlock.gif<td colspan="2" style="text-align: center">
InBlock.gif                 </td>
InBlock.gif<td></td>
InBlock.gif</tr>
InBlock.gif</table>
InBlock.gif                        <asp:Button ID="Button1" runat="server" Text="下一步" οnclick="Button1_Click" />
InBlock.gif                        <br />
InBlock.gif                        <br />
InBlock.gif                </asp:Panel>
InBlock.gif
InBlock.gif        </div><br/>
InBlock.gif        <asp:Panel ID="Panel2" runat="server" BorderStyle="Groove" Height="270px"
InBlock.gif                Visible="False"><h3 style="text-align: center">确认信息</h3>
InBlock.gif                <p style="text-align: center">
InBlock.gif                        用户名:<asp:Label ID="xusername" runat="server" Text="Label" Width="161px"></asp:Label>
InBlock.gif                </p>
InBlock.gif                <p style="text-align: center">
InBlock.gif                        密码:<asp:Label ID="xpassword" runat="server" Text="Label" Width="161px"></asp:Label>
InBlock.gif                </p>
InBlock.gif                <p style="text-align: center">
InBlock.gif                        联系电话:<asp:Label ID="xtelephone" runat="server" Text="Label" Width="161px"></asp:Label>
InBlock.gif                </p>
InBlock.gif                <p style="text-align: center">
InBlock.gif                        兴趣爱好:<asp:Label ID="xaihao" runat="server" Text="Label" Width="161px"></asp:Label>
InBlock.gif                </p>
InBlock.gif                <p style="text-align: center">
InBlock.gif                        <asp:Button ID="Button2" runat="server" Text="下一步" οnclick="Button2_Click" />
InBlock.gif                </p>
InBlock.gif        </asp:Panel>
InBlock.gif        <asp:Panel ID="Panel3" runat="server" Height="411px" Width="920px">
InBlock.gif                <h1 class="style1">恭喜您注册成功</h1>
InBlock.gif                <p class="style1">
InBlock.gif                        请切记您账号和密码:</p>
InBlock.gif                        <p style="text-align: center">
InBlock.gif                        用户名:<asp:Label ID="Label1" runat="server" Text="Label" Width="161px"></asp:Label>
InBlock.gif                </p>
InBlock.gif                <p style="text-align: center">
InBlock.gif                        密码:<asp:Label ID="Label2" runat="server" Text="Label" Width="161px"></asp:Label>
InBlock.gif                </p>
InBlock.gif                <p class="style1">
InBlock.gif                         </p>
InBlock.gif        </asp:Panel>
InBlock.gif        </form>
InBlock.gif</body>
InBlock.gif</html>

后台c#代码:

InBlock.gifusing System;
InBlock.gifusing System.Collections;
InBlock.gifusing System.Configuration;
InBlock.gifusing System.Data;
InBlock.gifusing System.Linq;
InBlock.gifusing System.Web;
InBlock.gifusing System.Web.Security;
InBlock.gifusing System.Web.UI;
InBlock.gifusing System.Web.UI.HtmlControls;
InBlock.gifusing System.Web.UI.WebControls;
InBlock.gifusing System.Web.UI.WebControls.WebParts;
InBlock.gifusing System.Xml.Linq;
InBlock.gif
namespace 容器控件
InBlock.gif{
InBlock.gif public partial class _Default : System.Web.UI.Page
InBlock.gif        {
InBlock.gif protected void Page_Load(object sender, EventArgs e)
InBlock.gif                {
InBlock.gif
this.Panel3.Visible = false;//放在这里实在页面加载时就把panel3隐藏
InBlock.gif                }
InBlock.gif
protected void Button1_Click(object sender, EventArgs e)
InBlock.gif                {
InBlock.gif this.Panel1.Visible = false;//点击按钮“下一步”是 panel1隐藏
InBlock.gif this.Panel2.Visible = true;//同时panel2显示出来
InBlock.gif this.xusername.Text = this.username.Text;// 把用户的信息放到自定义的label中,感觉很麻烦,希望会有更好的办法
InBlock.gif this.xpassword.Text = this.password1.Text;
InBlock.gif this.xtelephone.Text = this.telephone.Text;
InBlock.gif
InBlock.gif                }
InBlock.gif
protected void Button2_Click(object sender, EventArgs e)
InBlock.gif                {
InBlock.gif this.Panel2.Visible = false;//点击按钮“下一步”是 panel2隐藏
InBlock.gif this.Panel3.Visible = true;//同时panel3显示出来
InBlock.gif
InBlock.gif                }
InBlock.gif        }
InBlock.gif}

整个流程图比较简单,运用的主要是textbox控件,label控件,验证控件,Button控件,panel容器控件,其中验证空间运用的比较粗糙,继续改进。

转载于:https://www.cnblogs.com/shenzhoulong/archive/2010/04/21/1717108.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值