通常,海关服务器的控制将采用<代码>SaveViewState、LoadViewState
和TrackViewState
管理控制状态的方法。
I don t know how you re control is built so I can t give you the exact code, but here s an example of those methods being used in a control that I created:
protected override void LoadViewState(object savedState)
{
if (savedState != null)
{
object[] state = (object[])savedState;
if (state[0] != null)
base.LoadViewState(state[0]);
if (state[1] != null)
((IStateManager)ItemStyle).LoadViewState(state[1]);
if (state[2] != null)
((IStateManager)headerStyle).LoadViewState(state[2]);
if (state[3] != null)
((IStateManager)AlternatingItemStyle).LoadViewState(state[3]);
}
}
protected override object SaveViewState()
{
object[] state = new object[4];
state[0] = base.SaveViewState();
state[1] = itemStyle != null ? ((IStateManager)itemStyle).SaveViewState() : null;
state[2] = headerStyle != null ? ((IStateManager)headerStyle).SaveViewState() : null;
state[3] = alternatingItemStyle != null ? ((IStateManager)alternatingItemStyle).SaveViewState() : null;
return state;
}
protected override void TrackViewState()
{
base.TrackViewState();
if (itemStyle != null)
((IStateManager)itemStyle).TrackViewState();
if (headerStyle != null)
((IStateManager)headerStyle).TrackViewState();
if (alternatingItemStyle != null)
((IStateManager)alternatingItemStyle).TrackViewState();
}
除上述方法外,如果你想要从<代码>上重载信息,请<>/代码>标的,你可以执行<代码>。 缩略语
public virtual bool LoadPostData(string postDataKey, NameValueCollection postCollection)
{
string somePostedValue = postCollection["SomePostedValue"];
string anotherPostedValue = postCollection["AnotherPostedValue"];
}
public virtual void RaisePostDataChangedEvent()
{
}