S
Steve Drake
All,
I have 2 Questions, I want to save some custom information to the viewstate,
I cannot do this via the usual property get and set I override the
LoadViewState and SaveViewState, is this a good idea?
code :
protected override void LoadViewState(object savedState)
{
base.LoadViewState (savedState);
if (ViewState["CurrentSearch"] != null)
{
currentSearch = (AdvancedSearchItemCollection)
ViewState["CurrentSearch"] ;
}
else
{
currentSearch = new AdvancedSearchItemCollection();
}
}
protected override object SaveViewState()
{
ViewState["CurrentSearch"] = currentSearch;
return base.SaveViewState ();
}
It does work, but I was unsure if this was a bad way todo this.
Also... If a server event needs to change what controls are created, is it
good pratise to set ChildControlsCreated to false? I've used this mehod
loads as the CreateChildControls gets run before the events, setting
ChildControlsCreated to false cause the CreateChildControls to get re-run,
again is this a good idea, if not what alternitives do I have.
Steve
I have 2 Questions, I want to save some custom information to the viewstate,
I cannot do this via the usual property get and set I override the
LoadViewState and SaveViewState, is this a good idea?
code :
protected override void LoadViewState(object savedState)
{
base.LoadViewState (savedState);
if (ViewState["CurrentSearch"] != null)
{
currentSearch = (AdvancedSearchItemCollection)
ViewState["CurrentSearch"] ;
}
else
{
currentSearch = new AdvancedSearchItemCollection();
}
}
protected override object SaveViewState()
{
ViewState["CurrentSearch"] = currentSearch;
return base.SaveViewState ();
}
It does work, but I was unsure if this was a bad way todo this.
Also... If a server event needs to change what controls are created, is it
good pratise to set ChildControlsCreated to false? I've used this mehod
loads as the CreateChildControls gets run before the events, setting
ChildControlsCreated to false cause the CreateChildControls to get re-run,
again is this a good idea, if not what alternitives do I have.
Steve