Persist a stack across PostBacks?

W

Warren J. Hairston

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

TIA!
- Warren
 
J

Jason DeFontes

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top