Wednesday, March 21, 2012

Persist a stack across PostBacks?

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

TIA!
- WarrenYou 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

Warren J. Hairston wrote:

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

0 comments:

Post a Comment