Click here to Skip to main content
15,881,898 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
first page c# code:
protected void btn_Update_Click(object sender, EventArgs e)
{
Person p = new Person;
p.name = "john";
Session["person"] = p.
Response.Redirect("secondPage.aspx")
}

secondpage c# code:

protected void Page_Load(object sender, EventArgs e)
{
Person p = (person)Session["person"]
textbox1.Text = p.name;

}
Posted
Updated 25-Apr-13 6:17am
v2
Comments
OriginalGriff 25-Apr-13 12:06pm    
And?
What is your problem - you forgot to ask!
Member 9959371 25-Apr-13 12:11pm    
does not work it,, it is my problem
Sergey Alexandrovich Kryukov 25-Apr-13 12:24pm    
Such "questions" are not acceptable. "Not working" is not informative. It's just occasionally I can see what's the problem, please see my answer.
Next time, you want to make sure that you post is formulated as a question and provides essential information.
—SA
OriginalGriff 25-Apr-13 12:26pm    
"does not work" is not a very useful problem description - remember, we can't see your screen or access your HDD so we have to go on only what you tell us.
Do you get exceptions? Does anything happen? Give us information to help us help you!

1 solution

How do you think a session could possibly use such object? Here is a hint: the object should be serializeable. I believe that if you learn session state topics and pay attention to this aspect, you will find the right way by yourself.

Please look at this page and pay attention for "Note:", first one, counting from the top of page: http://msdn.microsoft.com/en-us/library/ms178581%28v=vs.100%29.aspx[^].

—SA
 
Share this answer
 
Comments
Espen Harlinn 25-Apr-13 19:24pm    
OP will have no person object assigned to the session variable when the page loads for the first time - and yes there are good reasons to only use something that is serializable, so a 5.
Sergey Alexandrovich Kryukov 25-Apr-13 19:44pm    
Yes, or making the required class serializeable.
Thank you, Espen.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900