protected void OnValidateUser(object sender, EventArgs e)
{
string connection = Convert.ToString(ConfigurationManager.ConnectionStrings["Connection"]);
SqlConnection con = new SqlConnection(connection);
SqlCommand cmd = new SqlCommand(String.Format("Select * from Users where userName ='{0}' and password='{1}'", txtUserID.Text.Trim(), txtPassword.Text.Trim()), con);
con.Open();
SqlDataReader idr = cmd.ExecuteReader();
userinfo user = new userinfo();
if (idr.Read())
{
Session["UserInfo"] = GetUserInfo(idr);
Response.Redirect("View-Info.aspx");
}
else
{
lblerror.Text = "Error : Please enter currect user name and password !";
}
}
public userinfo GetUserInfo(SqlDataReader idr)
{
return new userinfo
{
userName = Convert.ToString(idr["Username"]),
userId = Convert.ToInt32(idr["UserId"])
};
}