📄 memberlogin.ascx.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 System.Data.SqlClient;
public partial class UserControl_MemberLogin : System.Web.UI.UserControl
{
SqlConnection sqlconn = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Session["MName"] != null)
{
table2.Visible = true;
TABLE1.Visible = false;
MName.Text = Session["MName"].ToString();
}
}
}
protected void lbtnLogout_Click(object sender, EventArgs e)
{
table2.Visible = false;
TABLE1.Visible = true;
txtMName.Text = "";
txtMPwd.Text = "";
FormsAuthentication.SignOut();//清除验证信息
HttpContext.Current.Session.Clear();//清除Session内容
HttpContext.Current.Session.Abandon();//取消当前会话
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
sqlconn.Open();
SqlCommand sqlcom = new SqlCommand("proMemberInfo", sqlconn);
sqlcom.CommandType = CommandType.StoredProcedure;
sqlcom.Parameters.Add("@MemberName", SqlDbType.VarChar, 20).Value = txtMName.Text.Trim();
sqlcom.Parameters.Add("@MemberPwd", SqlDbType.VarChar, 20).Value = txtMPwd.Text.Trim();
SqlDataReader read = sqlcom.ExecuteReader();
if (read.Read())
{
table2.Visible = true;
TABLE1.Visible = false;
MName.Text = txtMName.Text;
Session["MName"] = txtMName.Text.Trim();
}
else
{
Response.Write("<script>alert('您输入的用户名或密码错误,请重新输入!');location='javascript:history.go(-1)';</script>");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -