protected void SetDestinationURL(object sender, EventArgs e)
{
if (loginMember())
Response.Redirect("~/Member/Home.aspx");
else if (loginManager())
Response.Redirect("~/Manager/Home.aspx");
else
Response.Write("<script language=javascript>alert('Unauthorized User Access')</script>");
}
protected Boolean loginMember()
{
TextBox txtID = lgLogin.FindControl("UserName") as TextBox;
TextBox txtPass = lgLogin.FindControl("Password") as TextBox;
SqlConnection conLogin = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
SqlCommand cmdLogin;
cmdLogin = new SqlCommand("SELECT UserName, Password FROM Member WHERE (UserName=@ID AND Password=@Pass)", conLogin);
cmdLogin.Parameters.AddWithValue("@ID", txtID.Text);
cmdLogin.Parameters.AddWithValue("@Pass", txtPass.Text);
conLogin.Open();
SqlDataReader myReader = cmdLogin.ExecuteReader();
if (myReader.Read())
return true;
else
return false;
}
protected Boolean loginManager()
{
TextBox txtID = lgLogin.FindControl("UserName") as TextBox;
TextBox txtPass = lgLogin.FindControl("Password") as TextBox;
SqlConnection conLogin = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
SqlCommand cmdLogin;
cmdLogin = new SqlCommand("SELECT UserName, Password FROM Manager WHERE (UserName=@ID AND Password=@Pass)", conLogin);
cmdLogin.Parameters.AddWithValue("@ID", txtID.Text);
cmdLogin.Parameters.AddWithValue("@Pass", txtPass.Text);
conLogin.Open();
SqlDataReader myReader = cmdLogin.ExecuteReader();
if (myReader.Read())
return true;
else
return false;
}
The codes from the above is i ever tried, but when i click the login button is doesn't redirect the specific pages.
The Login is insert from ASP.Net