Hi all.
Is it possible to:
1) put some value into, say, this property/field:
public ShoppingCart Cart;
defined in, say, _Default class, then
2) postback to this same page (not crosspage postback, PreviousPage will remain null) and
3) get value of Cart defined during previous request to this same page?
_Default class is derived from System.Web.UI.Page class, it's just a common ASP.NET web page.
Do I have to create some repository class just to store non-string values between page requests?
How to preserve value of Page's property between postbacks?
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Roei BarRank #1,271 · 1.4K reputationPosted Aug 4, 2009, 10:53 AM EDT
Mikhail3 reputationPosted Aug 5, 2009, 6:50 AM EDT
HttpContext.Current.Session[] seems more convenient to me, because ViewState requires serializable data.
But both seem almost as cumbersome as having custom repository class for just passing values between instances of Page.
Is there a way to preserve previous instance of Page and pass it to the next instance in property?
PreviousPage contains previous instance on cross-page Postback, but it's empty when Page posts back to itself.