📄 register.aspx.cs
字号:
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 MyBookShop.BLL;
using MyBookShop.Models;
public partial class UserManager_Register : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
if (!validateInput())
return;
User user = new User();
user.LoginId = this.txt_LoginId.Text;
user.LoginPwd = this.txt_LoginPwd.Text;
user.Name = this.txt_Name.Text;
user.Address = this.txt_Address.Text;
user.Phone = this.txt_Tele.Text;
user.Mail = this.txt_Email.Text;
user.UserState = new UserState();
user.UserState.Id = 1;
user.UserRole = new UserRole();
user.UserRole.Id = 1;
if (UserManager.Register(user))
this.ltMain.Text = "<script>alert('注册成功!请继续购物');window.location='../default.aspx'</script>";
else
this.ltMain.Text = "<script>alert('用户名已使用!请重新选择!')</script>";
}
/// <summary>
/// 判断输入框内容
/// </summary>
/// <returns></returns>
protected bool validateInput()
{
if (this.txt_LoginId.Text.Length == 0)
{
this.ltMain.Text = "<script>alert('请填写用户名!')</script>";
return false;
}
if (this.txt_LoginPwd.Text.Length == 0)
{
this.ltMain.Text = "<script>alert('请填写密码!')</script>";
return false;
}
if (this.txt_LoginPwd.Text.Trim() != this.txt_PwdAgain.Text.Trim())
{
this.ltMain.Text = "<script>alert('两次输入密码要一致!')</script>";
return false;
}
if (this.txt_Name.Text.Length == 0)
{
this.ltMain.Text = "<script>alert('请填写姓名!')</script>";
return false;
}
return true;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -