Oh, either way, with this method, if a page is re-navigated to via a non postback, you would lose any previous data because no matter what, whether viewstate or a normal hidden field, once the page is refreshed without a postback, that unique id is lost (because the viewstate/hidden field data is lost)
Main Topics
Browse All Topics





by: robkolskyPosted on 2009-09-14 at 06:24:15ID: 25325083
Sesions are shared across multiple instances of the same browser (i.e. tabs). If this is all within one page, you would be much better served by storing data in ViewState which is completely isolated to the specific instance of that page, and will persist as long as that copy of the page is active. That way data on multiple browser tabs will never interact with each other.
However, if you absolutely need session variables...
How you are going to handle this will depend on how you have structured your forms. Basically, you want to create a class that stores all the data you want to put into various session variables. You can then store a class instance in a session variable. First you need to create a viewstate field (or hidden field) that stores a uniqueid. You would only generate this id if the page is not posting back, otherwise you can pull the id from the viewstate field. You can then use that ID as the name of your session variable to be able to retrieve the variable.