please help me,
how to use session variable ,any body give sample coding in asp.net
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
sreekanth mgPosted Jun 28, 2006, 6:29 AM
Posted Jun 24, 2006, 10:40 PM
it is correct. But if you get the value from session object before you must validate this. using the property for validation
for example:
if session object contain string value.
public string _username
{
get
{
object o= Session["username"];
if(o!=null)
return (string)o;
else
return null;
}
}
In your method, you call the session like
string login name=_username; //_username is a property value that contain the Session value.
try this.
hema chandranPosted Jun 19, 2006, 6:28 AM
Thanks for ur sample code
LeePosted Jun 19, 2006, 6:20 AM
Hi,
in the "Global.asax.cs"
protected void Session_Start(Object sender, EventArgs e)
= Session["var"].ToString();
{
Session["var"] = "";
}
in your code
writing to a Session variable:
Session["var"] = "string";
reading from a Session variable:
I hope this helps!
Lee