Click here to Skip to main content
15,896,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello,
i have an object and i want to save it into session,my object is like
Pubic class myClass{

public string FirstName{ get; set; }
public string LastName { get; set; }
public int Age { get; set; }
}

i have like a workflow in each page i set a property of my objetct

i want to fill my session object in each of may page.aspx (i have 3 page)

What I have tried:

i have tried this code but i'm blocked

myClass state = new myClass();
Session["Adhesion"] = //here i want to fill each propertie in each page ;
Posted
Updated 22-Mar-17 2:41am

1 solution

Page 1:

myClass state = new myClass() { FirstName = "First" };
          Session["Adhesion"] = state;

Page 2:
myClass obj = ((myClass)Session["Adhesion"]);
           obj.LastName = "Last";
           Session["Adhesion"] = obj;

Page 3:
myClass obj = ((myClass)Session["Adhesion"]);
           obj.Age = 25;
           Session["Adhesion"] = obj;
 
Share this answer
 
Comments
Member 11573837 22-Mar-17 8:56am    
thank you Karthik Bangalore for answering me,
it help me, i have just one qst, how can i get the info from my session, i should make cast or what ??
Karthik_Mahalingam 22-Mar-17 9:50am    
Yes, like
myClass obj = ((myClass)Session["Adhesion"]);
obj.PropertyName = 'some';
var varibleName = obj.OtherProperty;

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