Persist a stack across PostBacks?

  • Thread starter Thread starter Warren J. Hairston
  • Start date Start date
W

Warren J. Hairston

Can anyone point me toward a solution for persisting non-controls (i.e.: a
stack) across PostBacks?

TIA!
- Warren
 
You can put pretty much anything, as long as it's Serializable, in the
page's ViewState and then retrieve it after a postback:

ViewState["Thing"] = myThing;
// later after postback...
myThing = (Thing)ViewState["Thing"];

There's some overhead associated with this because the ViewState is
downloaded as part of the page's html and uploaded again as part of the
request. If it's a large object you're better off saving it in the Session.

-Jason
 
Back
Top