What web controls save (by default) in ViewState ?

ViewState let web controls as much as users (programmer) to save and persist control state between page calls. Controls that wish to use viewstate services need to implement IstateManager interface. This interface consist from three methods (LoadViewState, SaveViewState , TrackViewState)  and  read only property (IsTrackingViewState).

 

In matter of fact System.Web.UI.Control class implement IstateManager and persist just control visibility. WebControl which derived from Control override LoadViewState and SaveViewState to preserve WebControl Enabled, AccessKey, TabIndex and ToolTip properties.

 

Every web control that derived from WebControl and need to save it own state data (such as Label, Grid , ListControl) override LoadViewState. SaveViewState isn't always overrides by Web Controls. Instead web controls use ViewState directly to save state.

 

Classes that not derived from Control (such as DataGridColumn, DataGridColumnCollection, Style, ListItem ,ListItemCollection) and want to use ViewSate need to implement IStateManager.

No Comments