Thursday, March 29, 2012

session varaibles with asp.net urgent help

hi i store some value in session object and later try to access it but the
value return from session variable is null
like
Session["Myname"]=txtmyname.Text;
Session["Age"]=txtAge.Text;
Response.Redirect("Welcome.aspx");
when this page loaded and iin page load event i called
lblMyname.Text=(string)session["Myname"];
lblAge.Text=(string)session["Age"];
it return null value instead of actual values.
i tried to store session value both in sql database and local memory both
result are sameamjad wrote:

Quote:

Originally Posted by

hi i store some value in session object and later try to access it but the
value return from session variable is null
like
Session["Myname"]=txtmyname.Text;
Session["Age"]=txtAge.Text;
Response.Redirect("Welcome.aspx");
when this page loaded and iin page load event i called
lblMyname.Text=(string)session["Myname"];
lblAge.Text=(string)session["Age"];
it return null value instead of actual values.
i tried to store session value both in sql database and local memory both
result are same


The possible chances are these:
1. you have started session somewhere else (on anyother page) as well
and
session is not abondened yet (with session.abonden).

2.

Quote:

Originally Posted by

lblMyname.Text=(string)session["Myname"]; //session's s should be capital i.e Session


3. or try this instead

lblMyname.Text=Session["email"].ToString();
3.
lblAge.Text=Session["Age"].ToString()
its not the Session i wrote small otherwise c # cannot compile. . i have
cancelled the session variable but still cannt display that value in another
page.

"nasirmajor@.yahoo.com" wrote:

Quote:

Originally Posted by

>
amjad wrote:

Quote:

Originally Posted by

hi i store some value in session object and later try to access it but the
value return from session variable is null
like
Session["Myname"]=txtmyname.Text;
Session["Age"]=txtAge.Text;
Response.Redirect("Welcome.aspx");
when this page loaded and iin page load event i called
lblMyname.Text=(string)session["Myname"];
lblAge.Text=(string)session["Age"];
it return null value instead of actual values.
i tried to store session value both in sql database and local memory both
result are same


>
The possible chances are these:
1. you have started session somewhere else (on anyother page) as well
and
session is not abondened yet (with session.abonden).
>
2.

Quote:

Originally Posted by

lblMyname.Text=(string)session["Myname"]; //session's s should be capital i.e Session


>
>
3. or try this instead
>
lblMyname.Text=Session["email"].ToString();
>
>


where have you cancelled/cleared the session?
when i do that instead of (string)Session["Age"] then it gave me that error
System.NullReferenceException: Object reference not set to an instance of an
object.

"nasirmajor@.yahoo.com" wrote:

Quote:

Originally Posted by

>
3.
lblAge.Text=Session["Age"].ToString()
>
>


amjad wrote:

Quote:

Originally Posted by

when i do that instead of (string)Session["Age"] then it gave me that error
System.NullReferenceException: Object reference not set to an instance of an
object.
>
>
"nasirmajor@.yahoo.com" wrote:
>

Quote:

Originally Posted by


3.
lblAge.Text=Session["Age"].ToString()


where ever if you have used session.clear or session.removeall replace
it with
session.abondon();
try whats happen?

0 comments:

Post a Comment