📄 reguser.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;
public partial class RegUser : System.Web.UI.Page
{
Controls ctrl = new Controls();
Users user = new Users();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnReg_Click(object sender, EventArgs e)
{
if (Request.Cookies["CheckCode"] == null)
{
JScript.Alert("您的浏览器设置已被禁用 Cookies,您必须设置浏览器允许使用 Cookies 选项后才能使用本系统。");//这里使用了js的方法
return;
}
if (!Equals(Request.Cookies["CheckCode"].Value, txtCode.Text.ToUpper()))
{
JScript.Alert("验证码错误,请输入正确的验证码。");
return;
}
string strUid = ctrl.GetText(txtUserName);
string strPwd = ctrl.GetText(Password);
string strAsk = ctrl.GetText(txtAsk);
string strAnwser = ctrl.GetText(txtAnwser);
if (!user.GetVldUser(strUid))
JScript.Alert("用户名已存在!");
else
{
if (vldInput())
{
if (!user.AddUsers(strUid, strPwd, strAsk, strAnwser))
JScript.Alert("注册失败!");
else
{
Response.Cookies.Add(new HttpCookie("username", user.GetUserId(ctrl.GetText(txtUserName))));
Response.Redirect("Default.aspx");
}
}
}
}
/// <summary>
/// 验证输入
/// </summary>
/// <returns></returns>
private bool vldInput()
{
#region
bool b = true;
if (ctrl.GetText(txtUserName).Length < 2 || ctrl.GetText(txtUserName).Length > 8)
{
JScript.Alert("用户名必须大于2位小于8位!");
b = false;
}
if (ctrl.GetText(Password).Length < 6 || ctrl.GetText(Password).Length > 16)
{
JScript.Alert("密码长度必须大于6位小于16位!");
b = false;
}
return b;
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -