一般性博客及游戏等用户的注册都会用到简单的登陆或者注册窗体:
web服务器控件部分要注意的是对用户输入数据的审查即对用户输入信息的登陆验证,还有就是对textbox控件的模式选择,选择textmode为password,以及对各控件的非空判定,有时候还需要用到正则表达式进行限制,对于单选按钮radio其group那么要设置在同一组内,以便选择是只能选择一个;每一个web控件必须是runat=“sever”!!!!
其主要代码如下:
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<body>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<form id=
"form1" runat=
"server">
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<table>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<tr runat=
"server">
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<td>用户名:</td>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<td><asp:TextBox runat=
"server" ID=
"username"></asp:TextBox></td>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<td>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<asp:RequiredFieldValidator ID=
"RequiredFieldValidator1" runat=
"server" ![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
ControlToValidate=
"username" Display=
"Dynamic" ErrorMessage=
"请正确输入用户名"></asp:RequiredFieldValidator><!对用户输入的信息进行非空验证,并为动态显示,如验证不通过弹出”请输入用户名“>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
</td>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
</tr>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<tr>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<td>密码:</td>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<td><asp:TextBox runat=
"server" ID=
"password1" TextMode=
"Password"></asp:TextBox> </td>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<td>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<asp:RequiredFieldValidator ID=
"RequiredFieldValidator2" runat=
"server" ![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
ControlToValidate=
"password1" Display=
"Dynamic" ErrorMessage=
"请输入密码!"></asp:RequiredFieldValidator><!对密码进行非空验证,并为动态显示,错误时提示:请输入密码>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
</td>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
</tr>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<tr>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<td>密码确认:</td>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<td><asp:TextBox runat=
"server" ID=
"password2" TextMode=
"Password"></asp:TextBox></td>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<td>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<asp:CompareValidator ID=
"CompareValidator1" runat=
"server" ![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
ControlToCompare=
"password1" ControlToValidate=
"password2" Display=
"Dynamic" ![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
ErrorMessage=
"请确认密码正确性"></asp:CompareValidator><!这里的controltocompare是对第一次输入的密码进行比较,测试十分保持一致>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
</td>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
</tr>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<tr>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<td>性别:</td>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<td>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<asp:RadioButton Text=
"男" ID=
"rd1" runat=
"server" GroupName=
"1" /><!groupname必须相同>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<asp:RadioButton Text=
"女" ID=
"rd2" runat=
"server" GroupName=
"1" />
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
</td>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<td></td>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
</tr>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<tr>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<td>联系电话:</td>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<td><asp:TextBox runat=
"server" ID=
"telephone"></asp:TextBox></td><!正则表达式偶还没学>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<td></td>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
</tr>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<tr>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<td>兴趣爱好:</td>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<td>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<asp:CheckBox runat=
"server" ID=
"cb1" Text=
"篮球" />
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<asp:CheckBox runat=
"server" ID=
"cb2" Text=
"足球" />
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<asp:CheckBox runat=
"server" ID=
"cb3" Text=
"排球" />
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<asp:CheckBox runat=
"server" ID=
"cb4" Text=
"读书" />
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
</td>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<td></td>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
</tr>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<tr>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<td colspan=
"2" style=
"text-align: center">
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<asp:Button ID=
"bt" runat=
"server" ![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
Text=
"提交" onclick=
"bt_Click" />
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
</td>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
<td></td>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
</tr>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
</table>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
</form>
![](http://shenzhoulong.blog.51cto.com/images/editer/InBlock.gif)
</body>
学会举一反三!