userlogin.aspx.cs
来自「手机网店源码」· CS 代码 · 共 82 行
CS
82 行
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace MobileOnlineShop
{
/// <summary>
/// UserLogin 的摘要说明。
/// </summary>
public class UserLogin : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button m_btnLogin;
protected System.Web.UI.WebControls.TextBox m_txtPassword;
protected System.Web.UI.HtmlControls.HtmlForm Form1;
protected System.Web.UI.WebControls.TextBox m_txtEmail;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.m_btnLogin.Click += new System.EventHandler(this.m_btnLogin_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void m_btnLogin_Click(object sender, System.EventArgs e)
{
if(this.m_txtEmail.Text == String.Empty)
{
Response.Write(@"<script language='javascript'>alert('用户名不能为空!');</script>");
return;
}
if(this.m_txtPassword.Text == String.Empty)
{
Response.Write(@"<script language='javascript'>alert('密码不能为空!');</script>");
return;
}
int customerID = MobileOnlineShop.DAL.CustomerDB.Login(this.m_txtEmail.Text,this.m_txtPassword.Text);
if(customerID != 0)
{
//调用CustomerDB的GetCustomerDetails方法返回一个Customers实例
MobileOnlineShop.Entities.Customers customer = MobileOnlineShop.DAL.CustomerDB.GetCustomerDetails(customerID);
Response.Cookies["UserName"].Value = customer.Name;
// Response.Cookies["UserName"].Expires.AddDays(30);
//根据customerID创建用户身份验证票据并将用户定向到其他页面
FormsAuthentication.RedirectFromLoginPage(customerID.ToString(),false);
}
else
Response.Write("<script language=javascript>alert('您尚未注册,请点击注册进入注册界面');</script>");
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?