There are probably several ways to tackle this but here is how I have done
it in the past.
You will need to override two methods for your control.
protected override void LoadViewState(object savedState);
protected override object SaveViewState()
SaveViewState returns the object that should be placed into viewstate. So
you intercept it and store it into session
protected override object SaveViewState()
{
//this will load the viewstate as normal
object o = base.SaveViewState();
//store it into session
System.Web.HttpContext.Current.Session[this.ID] = o;
//i think you need to return something (not null) in order for
LoadViewState
return new object();
}
protected override void LoadViewState( object savedState )
{
//load the savedState from Session
savedState = System.Web.HttpContext.Current.Session[this.ID];
//call base constructor
base.LoadViewState( savedState );
}
HTH,
bill
clsmith66 said:
Is it possible to store the same information about a control that would
be
saved in the ViewState in a Session state? I have a page with three treeview
controls and if I enable the view state for the controls I get huge
delays on
postbacks, but if I disable the viewstate I lose all my information. Any
sugesstions?