Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Typically, a custom server control will implement the <code>SaveViewState</code>, <code>LoadViewState</code>, and <code>TrackViewState</code> methods to manage the state of controls.</p> <p>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:</p> <pre><code>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(); } </code></pre> <p>Aside from the above methods, if you want to reload information from the <code>Request</code> object, you can implement the <code>IPostBackDataHandler</code> interface, which requires these two methods:</p> <pre><code>public virtual bool LoadPostData(string postDataKey, NameValueCollection postCollection) { string somePostedValue = postCollection["SomePostedValue"]; string anotherPostedValue = postCollection["AnotherPostedValue"]; } public virtual void RaisePostDataChangedEvent() { } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload