经验分享:C# asp.net 用户注册流程图(7)

2013 年 8 月 5 日3290

经验分享:C# asp.net 用户注册流程图(7)

  在asp.net中有两种容器控件,其中包括panel和placeholder控件。

  使用panel控件可以对控件进行分组。一帮助组织web窗体也的内容,将控件组织在面板中,可提供有关在运行时控件应如何分页显示的信息。这里也就是我们所说的在一个页面中通过“提交”或“下一步”按钮来显示不同的虚假页面,即通过隐藏可以实现,还有panel的外观属性,来设置panel的外观特性。

  简单的用户注册流程图:


 <%@PageLanguage="C#"AutoEventWireup="true"CodeBehind="Default.aspx.cs"Inherits="容器控件._Default"%>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://http://www.zjjv.com///TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://http://www.zjjv.com///1999/xhtml">
<headrunat="server">
<title>用户注册流程图</title>
<styletype="text/css">
.style1
{
text-align:center;
}
</style>
</head>
<body>
<formid="form1"runat="server">
<div>

<asp:PanelID="Panel1"runat="server"BorderStyle="Groove"Height="333px"
style="text-align:center"Width="909px"><h1>用户注册</h1>
<tablestyle="height:218px">
<trid="Tr1"runat="server">
<td>用户名:</td>
<td><asp:TextBoxrunat="server"ID="username"></asp:TextBox></td>
<td>
<asp:RequiredFieldValidatorID="RequiredFieldValidator1"runat="server"
ControlToValidate="username"Display="Dynamic"ErrorMessage="请正确输入用户名"></asp:RequiredFieldValidator><!对用户输入的信息进行非空验证,并为动态显示,如验证不通过弹出”请输入用户名“>
</td>
</tr>
<tr>
<td>密码:</td>
<td><asp:TextBoxrunat="server"ID="password1"TextMode="Password"></asp:TextBox></td>
<td>
<asp:RequiredFieldValidatorID="RequiredFieldValidator2"runat="server"
ControlToValidate="password1"Display="Dynamic"ErrorMessage="请输入密码!"></asp:RequiredFieldValidator><!对密码进行非空验证,并为动态显示,错误时提示:请输入密码>
</td>
</tr>
<tr>
<td>密码确认:</td>
<td><asp:TextBoxrunat="server"ID="password2"TextMode="Password"></asp:TextBox></td>
<td>
<asp:CompareValidatorID="CompareValidator1"runat="server"
ControlToCompare="password1"ControlToValidate="password2"Display="Dynamic"
ErrorMessage="请确认密码正确性"></asp:CompareValidator><!这里的controltocompare是对第一次输入的密码进行比较,测试十分保持一致>
</td>
</tr>
<tr>
<td>性别:</td>
<td>
<asp:RadioButtonText="男"ID="rd1"runat="server"GroupName="1"/><!groupname必须相同>
<asp:RadioButtonText="女"ID="rd2"runat="server"GroupName="1"/>
</td>
<td></td>
</tr>
<tr>
<td>联系电话:</td>
<td><asp:TextBoxrunat="server"ID="telephone"></asp:TextBox></td><!正则表达式偶还没学>
<td>
<asp:RangeValidatorID="RangeValidator1"runat="server"ErrorMessage="请输入电话号码"
MaximumValue="199999999999"MinimumValue="0"
ControlToValidate="telephone"></asp:RangeValidator><!比较粗糙的定义范围,最小值为0.,最大值为19999999999>
</td>
</tr>
<tr>
<td>兴趣爱好:</td>
<td>
<asp:CheckBoxrunat="server"ID="cb1"Text="篮球"/>
<asp:CheckBoxrunat="server"ID="cb2"Text="足球"/>
<asp:CheckBoxrunat="server"ID="cb3"Text="排球"/>
<asp:CheckBoxrunat="server"ID="cb4"Text="读书"/>
</td>
<td></td>
</tr>
<tr>
<tdcolspan="2"style="text-align:center">
</td>
<td></td>
</tr>
</table>
<asp:ButtonID="Button1"runat="server"Text="下一步"onclick="Button1_Click"/>
<br/>
<br/>
</asp:Panel>

</div><br/>
<asp:PanelID="Panel2"runat="server"BorderStyle="Groove"Height="270px"
Visible="False"><h3style="text-align:center">确认信息</h3>
<pstyle="text-align:center">
用户名:<asp:LabelID="xusername"runat="server"Text="Label"Width="161px"></asp:Label>
</p>
<pstyle="text-align:center">
密码:<asp:LabelID="xpassword"runat="server"Text="Label"Width="161px"></asp:Label>
</p>
<pstyle="text-align:center">
联系电话:<asp:LabelID="xtelephone"runat="server"Text="Label"Width="161px"></asp:Label>
</p>
<pstyle="text-align:center">
兴趣爱好:<asp:LabelID="xaihao"runat="server"Text="Label"Width="161px"></asp:Label>
</p>
<pstyle="text-align:center">
<asp:ButtonID="Button2"runat="server"Text="下一步"onclick="Button2_Click"/>
</p>
</asp:Panel>
<asp:PanelID="Panel3"runat="server"Height="411px"Width="920px">
<h1class="style1">恭喜您注册成功</h1>
<pclass="style1">
请切记您账号和密码:</p>
<pstyle="text-align:center">
用户名:<asp:LabelID="Label1"runat="server"Text="Label"Width="161px"></asp:Label>
</p>
<pstyle="text-align:center">
密码:<asp:LabelID="Label2"runat="server"Text="Label"Width="161px"></asp:Label>
</p>
<pclass="style1">
</p>
</asp:Panel>
</form>
</body>
</html>
  后台c#代码:

  


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

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

  本文出自 “神舟龙” 博客,请务必保留此出处http://http://www.zjjv.com///1191789/296058

编辑推荐:

1. 经验分享:C# asp.net sqldatasource(6)

2. C# 判断系统是否静音的音频操作

3. C# Asp.net 多数组索引的解决方法

相关文章

关键词: 技巧

责任编辑:谢妍妍

专题推荐

原创文章

微博互动

白皮书

0 0