62,244
社区成员




<asp:TextBox ID="pwd" runat="server" TextMode="Password"></asp:TextBox>
<asp:Panel ID="Panel2" runat="server" Height="400px" Width="680px">
<table border="1">
<tr>
<td align="center" colspan="4">
请填写下列个人信息</td>
</tr>
<tr>
<td style="width: 709px; height: 26px">
真实姓名:</td>
<td style="width: 100px; height: 26px">
<asp:TextBox ID="zsname" runat="server"></asp:TextBox></td>
<td class="style1">
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="zsname" ErrorMessage="姓名不能为空" Width="100px"></asp:RequiredFieldValidator>
</td>
<td rowspan="6" class="style4">
<asp:Image ID="Image1" runat="server" Height="208px" Width="184px" /></td>
</tr>
<tr>
<td style="width: 709px; height: 13px">
性别:</td>
<td style="width: 100px; height: 13px">
<asp:RadioButtonList ID="sex" runat="server" RepeatDirection="Horizontal">
<asp:ListItem>男</asp:ListItem>
<asp:ListItem>女</asp:ListItem>
</asp:RadioButtonList></td>
<td class="style2">
</td>
</tr>
<tr>
<td style="width: 709px; height: 21px">
出生日期:</td>
<td style="width: 100px; height: 21px">
<asp:TextBox ID="birthday" runat="server"></asp:TextBox></td>
<td class="style3">
</td>
</tr>
<tr>
<td style="width: 709px; height: 21px">
省份:</td>
<td style="width: 100px; height: 21px">
<asp:DropDownList ID="province" runat="server">
<asp:ListItem>湖北</asp:ListItem>
<asp:ListItem>河北</asp:ListItem>
</asp:DropDownList></td>
<td class="style3">
</td>
</tr>
<tr>
<td style="width: 709px; height: 21px">
城市:</td>
<td style="width: 100px; height: 21px">
<asp:DropDownList ID="city" runat="server">
<asp:ListItem>武汉</asp:ListItem>
<asp:ListItem>咸宁</asp:ListItem>
<asp:ListItem>汉川</asp:ListItem>
</asp:DropDownList></td>
<td class="style3">
</td>
</tr>
<tr>
<td style="width: 709px; height: 13px">
教育程度:</td>
<td style="width: 100px; height: 13px">
<asp:DropDownList ID="jiaoyu" runat="server">
<asp:ListItem>高中</asp:ListItem>
<asp:ListItem>本科</asp:ListItem>
<asp:ListItem>专科</asp:ListItem>
<asp:ListItem>硕士</asp:ListItem>
</asp:DropDownList></td>
<td class="style2">
</td>
</tr>
<tr>
<td style="width: 709px; height: 13px">
月收入:</td>
<td style="width: 100px; height: 13px">
<asp:DropDownList ID="shouru" runat="server">
<asp:ListItem>1000以上</asp:ListItem>
<asp:ListItem>5000以上</asp:ListItem>
<asp:ListItem>3000以上</asp:ListItem>
</asp:DropDownList></td>
<td class="style2">
</td>
<td class="style5">
<asp:Button ID="Button3" runat="server" Text="加载" OnClick="Button3_Click" />
<asp:FileUpload ID="FileUpload1" runat="server" EnableTheming="True" Width="56px" /></td>
</tr>
<tr>
<td style="width: 709px; height: 11px">
兴趣爱好:</td>
<td style="height: 11px" colspan="3" align="left">
<asp:CheckBoxList ID="aihao" runat="server" RepeatDirection="Horizontal">
<asp:ListItem>三国杀</asp:ListItem>
<asp:ListItem>DNF</asp:ListItem>
</asp:CheckBoxList></td>
</tr>
<tr>
<td colspan="4" style="height: 14px" align="center">
<asp:Button ID="Button5" runat="server" Text="下一步" OnClick="Button5_Click" /></td>
</tr>
</table>
</asp:Panel>
<br />
<br />
<br />
<br />
<br />
<asp:Panel ID="Panel4" runat="server" Height="197px" Width="684px">
<table border="1" style="width: 680px">
<tr>
<td align="center" colspan="3">
填写联系方式</td>
</tr>
<tr>
<td style="width: 269px; height: 25px" align="right">
邮政编码:</td>
<td style="width: 154px; height: 25px">
<asp:TextBox ID="youbian" runat="server"></asp:TextBox></td>
<td style="width: 458px; height: 25px" align="left">
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="RegularExpressionValidator"
ValidationExpression="\d{6}" ControlToValidate="youbian"></asp:RegularExpressionValidator></td>
</tr>
<tr>
<td style="width: 269px; height: 21px" align="right">
身份证号:</td>
<td style="width: 154px; height: 21px">
<asp:TextBox ID="shenfen" runat="server"></asp:TextBox></td>
<td style="width: 458px; height: 21px" align="left">
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ErrorMessage="RegularExpressionValidator" ControlToValidate="shenfen" ValidationExpression="\d{17}[\d|X]|\d{15}"></asp:RegularExpressionValidator></td>
</tr>
<tr>
<td style="width: 269px; height: 26px" align="right">
家庭住址:</td>
<td style="width: 154px; height: 26px">
<asp:TextBox ID="address" runat="server"></asp:TextBox></td>
<td style="width: 458px; height: 26px">
</td>
</tr>
<tr>
<td style="width: 269px; height: 12px" align="right">
Email:</td>
<td style="width: 154px; height: 12px">
<asp:TextBox ID="email" runat="server"></asp:TextBox></td>
<td style="width: 458px; height: 12px" align="left">
<asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" ErrorMessage="RegularExpressionValidator"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ControlToValidate="email"></asp:RegularExpressionValidator></td>
</tr>
<tr>
<td align="center" colspan="3" style="height: 24px">
<asp:Button ID="Button6" runat="server" Text="完成" OnClick="Button6_Click" /></td>
</tr>
</table>
</asp:Panel>
</center>
</div>
</form>
</body>
</html>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="zhuce.aspx.cs" Inherits="zhuce" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<style type="text/css">
.style1
{
height: 26px;
width: 877px;
}
.style2
{
height: 13px;
width: 877px;
}
.style3
{
height: 21px;
width: 877px;
}
.style4
{
width: 191px;
}
.style5
{
height: 13px;
width: 191px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div >
<center>
<asp:Panel ID="Panel3" runat="server" Height="168px" Width="672px">
<table border="1" >
<tr>
<td align="center" style="width: 656px; height: 46px">
用户协议</td>
</tr>
<tr>
<td style="width: 656px; height: 103px">
<br />
无聊的人啊@<br />
</td>
</tr>
<tr>
<td style="width: 656px; height: 7px" align="center">
<br />
<asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatDirection="Horizontal"
AutoPostBack="True"
onselectedindexchanged="RadioButtonList1_SelectedIndexChanged1" >
<asp:ListItem Value="1">同意</asp:ListItem>
<asp:ListItem Value="0">不同意</asp:ListItem>
</asp:RadioButtonList></td>
</tr>
<tr>
<td style="width: 656px; height: 56px" align="center">
<asp:Button ID="Button1" runat="server" Text="下一步" OnClick="Button1_Click1" /></td>
</tr>
</table>
</asp:Panel>
<br />
<br />
<br />
<br />
<br />
<asp:Panel ID="Panel1" runat="server" Height="184px" Width="680px">
<table border="1">
<tr>
<td align="center" colspan="2" style="height: 55px">
登录信息</td>
</tr>
<tr>
<td align="right" style="width: 418px; height: 21px">
用户名:</td>
<td style="width: 634px; height: 21px" align="left">
<asp:TextBox ID="username" runat="server"></asp:TextBox>
<asp:CustomValidator ID="CustomValidator1" runat="server" ControlToValidate="username"
OnServerValidate="CustomValidator1_ServerValidate">用户已经存在</asp:CustomValidator></td>
</tr>
<tr>
<td align="right" style="width: 418px; height: 26px">
密码:</td>
<td align="left" style="width: 634px; height: 26px">
<asp:TextBox ID="pwd" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td align="right" style="width: 418px">
重复密码:</td>
<td style="width: 634px" align="left">
<asp:TextBox ID="rpwd" runat="server"></asp:TextBox>
<asp:CompareValidator ID="CompareValidator1" runat="server" ErrorMessage="输入的密码不一致" ControlToCompare="pwd" ControlToValidate="rpwd"></asp:CompareValidator></td>
</tr>
<tr>
<td colspan="2" style="height: 22px" align="center">
<asp:Button ID="Button2" runat="server" Text="下一步" OnClick="Button2_Click" /></td>
</tr>
</table>
</asp:Panel>
<br />
<br />
<br />
<br />
<br />
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
/// <summary>
/// ljm 的摘要说明
/// </summary>
public class ljm
{
public ljm()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public static SqlConnection createCon()
{
return new SqlConnection("server=(local);uid=sa;pwd=123456;database=ljm;");
}
public static bool panduan(string userName)
{
SqlConnection con = ljm.createCon();
con.Open();
SqlCommand cmd =new SqlCommand("select count(*) from xinxi where 用户名='" + userName + "'", con);
int i = (int)cmd.ExecuteScalar();
con.Close();
if (i > 0)
return true;
else
return false;
}
}
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class zhuce : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.Panel3.Visible = true;
this.Panel1.Visible = false;
this.Panel2.Visible = false;
this.Panel4.Visible = false;
Button1.Enabled = false;
// this.pwd.Attributes.Add("value", Request["pwd"]);
}
}
protected void Button3_Click(object sender, EventArgs e)
{
FileUpload1.PostedFile.SaveAs(Server.MapPath("upFile") + "\\" + FileUpload1.FileName);
Image1.ImageUrl = "upFile\\" + FileUpload1.FileName;
}
protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
{
if (ljm.panduan(username.Text))
{
CustomValidator1.IsValid =false;
}
else
{
CustomValidator1.IsValid = true;
}
}
protected void Button1_Click1(object sender, EventArgs e)
{
if (RadioButtonList1.SelectedValue == "1")
{
this.Panel3.Visible = false;
this.Panel1.Visible = true;
}
}
protected void Button2_Click(object sender, EventArgs e)
{
if (ljm.panduan(username.Text))
{
CustomValidator1.IsValid = false;
}
else
{
CustomValidator1.IsValid = true;
}
if (CustomValidator1.IsValid)
{
this.Panel1.Visible = false;
this.Panel2.Visible = true;
}
else
{
// Response.Write("<script lanuage=javascript>alert('用户名存在!!!')</script>");
pwd.Text = "";
rpwd.Text = "";
SetFocus(username);
}
}
protected void Button5_Click(object sender, EventArgs e)
{
this.Panel2.Visible = false;
this.Panel4.Visible = true;
}
protected void Button6_Click(object sender, EventArgs e)
{
try
{
String userid1 = username.Text;
String mima =pwd.Text ;
String name = zsname.Text;
String birthday1 = birthday.Text;
String sex1 = sex.SelectedValue;
String province1 = province.Text;
String city1 = city.Text;
String jiaoyu1 = jiaoyu.Text;
String aihao1 = "";
foreach (ListItem i in aihao.Items)
{
if (i.Selected)
aihao1 += " " + i;
}
String shouru1 = shouru.Text;
String img = Image1.ImageUrl.ToString();
String email1 = email.Text;
String youbian1 = youbian.Text;
String shenfen1 = shenfen.Text;
String dizhi = address.Text;
SqlConnection con = ljm.createCon();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "insert xinxi(用户名,密码,真实姓名,性别,省份,城市,教育程度,爱好,月收入,图像,邮编,身份证号,地址,email)values('" + userid1 + "','" +mima+ "','" + name + "','" + sex1 + "','" + province1 + "','" + city1 + "','" + jiaoyu1 + "','" + aihao1 + "','" + shouru1 + "','" + img + "','" + youbian1 + "','" + shenfen1 + "','" + dizhi + "','" + email1 + "')";
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
// Response.Redirect("success.aspx");
Response.Write(pwd.Text);
}
catch (SqlException) { Response.Write("<script>alert('注册错误!')</script>"); };
}
protected void RadioButtonList1_SelectedIndexChanged1(object sender, EventArgs e)
{
if (RadioButtonList1.SelectedValue == "1")
{
Button1.Enabled = true;
}
if (RadioButtonList1.SelectedValue == "0")
{
Button1.Enabled = false;
}
}
}