为什么我的登入提示不会出来?还有就是登入成功后,不应该看见的为什么还在???
private void Btn_Login_Click(object sender, System.EventArgs e)
{
//int radio = Int32.Parse(RadioButtonList1.SelectedItem.Value);
if(Page.IsValid)
{
if(Session["UserName"]==null)
{
Label1.Visible = false;
}
else
{
T1.Visible = false;
}
if(IsUserIdentify())
{
Response.Redirect("default.aspx");
Label1.Text = "欢迎," + Session["UserName"].ToString();
T1.Visible = false;
}
else
{
this.errormessage.Visible = true;
}
}
}
private bool IsUserIdentify()
{
SqlConnection conn = new SqlConnection((string)Application["sqlConnectionString"]);
conn.Open();
string sql = "select ID from Register where UserName ='"+ this.Txb_UserName.Text
+ "'and Password ='"+ this.Txb_Pw.Text +"' ";
SqlCommand cmd = new SqlCommand(sql,conn);
SqlDataReader reader = cmd.ExecuteReader();
if(reader.Read())
{
Session["userid"]=reader["ID"].ToString();
return true;
}
else
{
return false;
}
}