if ((UserEmail.Value == uname) && (UserPass.Value == pass)) {
FormsAuthentication.RedirectFromLoginPage(UserEmail.Value, PersistCookie.Checked);
string Session["UserID"] = dbread["ID"] ;
string Session["UserName"] = dbread["uname"] ;
string Session["password"] = dbread["pass"] ;
}
else {
Msg.Text = "Invalid Credentials: Please try again";
}
Help, i wrote this to have session variables so i could transfer data from page to page, but i get an error : CS0650: Syntax error, bad array declarator. To declare a managed array the rank specifier precedes the variable's identifier
PLease help
Thank you so muchYour current code, even if it compiled, would not hav worked, because when you call RedirectFromLoginPage, the balance of the code will not be executed.
You do not have to define the Session[] variables with a type (string). You need to call ToString() on the DataReader columns, because they are objects, not strings.
if ((UserEmail.Value == uname) && (UserPass.Value == pass)) {
Session["UserID"] = dbread["ID"].ToString() ;
Session["UserName"] = dbread["uname"].ToString();
Session["password"] = dbread["pass"].ToString();
FormsAuthentication.RedirectFromLoginPage(UserEmail.Value, PersistCookie.Checked);}
else {
Msg.Text = "Invalid Credentials: Please try again";
}
thanx greatly, i have done that, but how do i call the session variable up on the next page?
string UserName=Session["UserName"].ToString();
Again, the indexed property is an object, so use .ToString() to get the string value.
thanx man very much i really appreciate it
0 comments:
Post a Comment