Using session to get/set object properties everytime

BrermCalsense

New Member
I tried searching for this but I'm not even sure how to phrase it for the search.What I'm attempting to do is have a class that everytime I access it to change it, I'm really getting and setting the value from session.Here's what I'm trying to do (what I have so far.):\[code\]public class example{ public int prop1 {get;set;} public static example Instance { return (example)(HttpContext.Current.Session["exampleClass"] ?? new example()); }}public class main{ protected void Page_Load(object sender, EventArgs e) { example.Instance.prop1 = "aaa"; //stores value into session txtInput.Text = example.Instance.prop1; //retrieves value from session }}\[/code\]I hope that makes sense on what I am trying to do.Any help would be appreciated, thank you.
 
Top