Pardon me for asking a mundane newbie question but I seem to be stuck in a class life-cycle limbo.
So I have my page
public partial class DefaultPage : BasePage
{
...
}
And the BasePage like this:
public class BasePage : System.Web.UI.Page
{
private Model _model;
public BasePage()
{
if (ViewState["_model"] != null)
_modal = ViewState["_model"] as Modal;
else
_modal = new Modal();
}
//I want something to save the Modal when the life cycle ends
[serializable]
public class Model
{
public Dictionary<int, string> Status = new Dictionary<int, string>();
... //other int, string, double fields
}
public class PageManager()
{ //code here; just some random stuff
}
}
Now I just want to get the Modal on page load, which I do from constructor. How can I save it on page unload? I can't use destructor as It's not reliable.
What is the best solution to this scenario?
Thanks.