bootstrap網站後臺從設計到開發之登錄
節後綜合征緩了兩天,今天把登錄界面的主要後臺代碼分享給大家。
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
txtUserName.Text = Utils.GetCookie("DTRememberName");
}
}
protected void login_Click(object sender, EventArgs e)
{
string userName = txtUserName.Text.Trim();
string userPwd = txtPassword.Text.Trim();
if (userName.Equals("") || userPwd.Equals(""))
{
msgtip.InnerHtml = "請輸入用戶名和密碼!";
return;
}
BLL.T_Manager bll = new BLL.T_Manager();
Model.T_Manager model = bll.GetModel(userName, userPwd);
if (model == null)
{
msgtip.InnerHtml = "用戶名或密碼錯誤,請重試!";
return;
}
Session.Timeout = 45;
Session[ManagePage.SESSION_ADMIN_INFO] = model;
Utils.WriteCookie("DTRememberName", model.user_name, 14400);
Utils.WriteCookie("AdminName", "cms", model.user_name);
Utils.WriteCookie("AdminPwd", "cms", model.password);
Response.Redirect("");
}
bootstrap網站後臺從設計到開發之登錄