WB 例子 审核 注册页面 注册的都是未审核的
前台HTML代码
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ZhuCe.aspx.cs" Inherits="ZhuCe" %> <!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> .dl { margin:0px auto; padding:0px; left:400px; width:304px ; height:358px; } </style> </head> <body> <form id="form1" runat="server"> <div class="dl"> <h2> 注册界面</h2> <p> </p> <asp:Label ID="Label1" runat="server" Text="用户名:"></asp:Label> <asp:TextBox ID="txtUserName" runat="server"></asp:TextBox> <br /> <br /> <asp:Label ID="Label2" runat="server" Text="密 码:"></asp:Label> <asp:TextBox ID="txtPassWork" runat="server" TextMode="Password"></asp:TextBox> <br /> <br /> <asp:Label ID="Label3" runat="server" Text="姓 名:"></asp:Label> <asp:TextBox ID="txtName" runat="server"></asp:TextBox> <br /> <br /> <asp:Label ID="Label4" runat="server" Text="性 别:"></asp:Label> <asp:RadioButton ID="RadioButton1" runat="server" Checked="True" GroupName="sex" Text="男" /> <asp:RadioButton ID="RadioButton2" runat="server" GroupName="sex" Text="女" /> <br /> <br /> <asp:Label ID="Label5" runat="server" Text="生 日:"></asp:Label> <asp:TextBox ID="txtBirthday" runat="server"></asp:TextBox> <br /> <br /> <br /> <asp:Button ID="Button1" runat="server" Text="注 册" OnClick="Button1_Click" /> </div> </form> </body> </html>
后台C#代码:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class ZhuCe : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { TestDataContext context = new TestDataContext(); //取值 string uid = txtUserName.Text; string pwd = txtPassWork.Text; string name = txtName.Text; bool sex = RadioButton1.Checked; DateTime birthday = Convert.ToDateTime(txtBirthday.Text); //先造对象 Users data = new Users(); data.UserName = uid; data.PassWord = pwd; data.Name = name; data.Sex = sex; data.Birthday = birthday; data.State = 0; //往数据库中添加数据 context.Users.InsertOnSubmit(data); context.SubmitChanges(); } }
网页显示: