If you want the value to be persisted between pages, then session is the right direction.
You can save in a HiddenField but that will be only accessible on the particular page where that is define.. So use a Session varible..
//To Save a Value in a session
Session["Id"] = yourValue ; // Lets say its a string
//To access the Session variable use this
String id = string.Empty ;
If(Session["Id"] != null)
{
id = Session["Id"] As string ;
}
Marked as answer by mcupryk on Aug 08, 2012 02:54 PM
You want your session to time out. If it never timed out, your users' informatin would sit in RAM on the server forever until the server ran out of room in memory. I think the default timeout is 10 minutes. Do you have a need for your users to be on your
site without any activity for over 10 minutes? Each time they request or refresh a page, the 10 minute timer is reset. If so, how long do you want to keep thier session alive before assuming they are not coming back and clearing out the server memory?
mcupryk
Member
243 Points
392 Posts
Storing the current value of an orderid in a usercontrol base class.
Aug 07, 2012 08:21 PM|LINK
I need to be able to store the orderid in when the usercontrol defines
: BaseUserControl
I am just wondering if there is an example some can show me.
I would like to be able to retreive it on any page.
This would be of great help.
MattsDotNetU...
Contributor
3178 Points
515 Posts
Re: Storing the current value of an orderid in a usercontrol base class.
Aug 07, 2012 08:28 PM|LINK
If you need to save it on one page and use it on another, I think Session would be the way to go.
http://msdn.microsoft.com/en-us/library/ms972429.aspx
sushanth009
Contributor
6243 Points
1168 Posts
Re: Storing the current value of an orderid in a usercontrol base class.
Aug 07, 2012 10:22 PM|LINK
If you want the value to be persisted between pages, then session is the right direction.
You can save in a HiddenField but that will be only accessible on the particular page where that is define.. So use a Session varible..
//To Save a Value in a session Session["Id"] = yourValue ; // Lets say its a string //To access the Session variable use this String id = string.Empty ; If(Session["Id"] != null) { id = Session["Id"] As string ; }mcupryk
Member
243 Points
392 Posts
Re: Storing the current value of an orderid in a usercontrol base class.
Aug 08, 2012 12:42 PM|LINK
The only problem is how do I set the session to not time out.
MattsDotNetU...
Contributor
3178 Points
515 Posts
Re: Storing the current value of an orderid in a usercontrol base class.
Aug 08, 2012 01:29 PM|LINK
You want your session to time out. If it never timed out, your users' informatin would sit in RAM on the server forever until the server ran out of room in memory. I think the default timeout is 10 minutes. Do you have a need for your users to be on your site without any activity for over 10 minutes? Each time they request or refresh a page, the 10 minute timer is reset. If so, how long do you want to keep thier session alive before assuming they are not coming back and clearing out the server memory?
mcupryk
Member
243 Points
392 Posts
Re: Storing the current value of an orderid in a usercontrol base class.
Aug 08, 2012 02:55 PM|LINK
ok that sounds good if the session var is null goto expire page.