📄 register.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Configuration;
using HouseSystem.Components;
using HouseSystem.Modal;
namespace HouseSystem
{
/// <summary>
/// Register 的摘要说明。
/// </summary>
public class Register : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label lblMsg;
protected System.Web.UI.WebControls.LinkButton linkCheckUserName;
protected System.Web.UI.HtmlControls.HtmlInputText txtUserName;
protected System.Web.UI.HtmlControls.HtmlInputText txtPassword;
protected System.Web.UI.HtmlControls.HtmlInputText txtPassword2;
protected System.Web.UI.HtmlControls.HtmlInputText txtQuestion;
protected System.Web.UI.HtmlControls.HtmlInputText txtAnswer;
protected System.Web.UI.HtmlControls.HtmlInputText txtName;
protected System.Web.UI.HtmlControls.HtmlInputText txtTel1;
protected System.Web.UI.HtmlControls.HtmlInputText txtTel2;
protected System.Web.UI.HtmlControls.HtmlInputText txtEmail;
protected System.Web.UI.HtmlControls.HtmlInputCheckBox chkAgreement;
protected System.Web.UI.HtmlControls.HtmlInputButton btnSubmit;
protected string WebName;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
this.WebName = ConfigurationSettings.AppSettings["My_WebName"];
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.linkCheckUserName.Click += new System.EventHandler(this.linkCheckUserName_Click);
this.btnSubmit.ServerClick += new System.EventHandler(this.btnSubmit_ServerClick);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void linkCheckUserName_Click(object sender, System.EventArgs e)
{
string text1 = "1";
string text2 = this.txtUserName.Value.Trim();
if ((text2 == null) || (text2 == ""))
{
text1 = "2";
}
if (Users.IsUserExist(text2))
{
text1 = "-1";
}
else
{
text1 = "1";
}
base.Response.Write("<script>window.open ('Msg.aspx?type=" + text1 + "', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=245,height=135');</script>");
}
private void btnSubmit_ServerClick(object sender, System.EventArgs e)
{
if (!this.chkAgreement.Checked)
{
this.lblMsg.Text = "请输入用户名!";
}
else
{
UserInfo info1 = new UserInfo();
info1.UserName = Tools.CheckStrInput(this.txtUserName.Value);
info1.UserPass = Tools.CheckStrInput(this.txtPassword.Value);
info1.Question = Tools.CheckStrInput(this.txtQuestion.Value);
info1.Answer = Tools.CheckStrInput(this.txtAnswer.Value);
info1.Name = Tools.CheckStrInput(this.txtName.Value);
info1.Sex = byte.Parse(base.Request.Form["radSex"]);
info1.Tel1 = Tools.CheckStrInput(this.txtTel1.Value);
info1.Tel2 = Tools.CheckStrInput(this.txtTel2.Value);
info1.Email = Tools.CheckStrInput(this.txtEmail.Value);
int num1 = Users.Add(info1);
if (num1 > 0)
{
base.Response.Redirect("RegisterOk.aspx", false);
}
else if (num1 == -1)
{
this.lblMsg.Text = "<div align='center'>对不起,已经有人注册了!</div>";
}
else
{
this.lblMsg.Text = "注册发生其他错误.";
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -