Export (0) Print
Expand All

IStateManager.LoadViewState Method

When implemented by a class, loads the server control's previously saved view state to the control.

[Visual Basic]
Sub LoadViewState( _
   ByVal state As Object _
)
[C#]
void LoadViewState(
   object state
);
[C++]
void LoadViewState(
   Object* state
);
[JScript]
function LoadViewState(
   state : Object
);

Parameters

state
An Object that contains the saved view state values for the control.

Example

[Visual Basic] 
' Implement the LoadViewState method. If the saved view state
' exists, the view-state value is loaded to the MyItem 
' control. 
Sub LoadViewState(savedState As Object) Implements IStateManager.LoadViewState
   _message = CStr(_viewstate("message"))
   If Not (savedState Is Nothing) Then
      CType(_viewstate, IStateManager).LoadViewState(savedState)
   End If
End Sub 'LoadViewState

[C#] 
// Implement the LoadViewState method. If the saved view state
// exists, the view-state value is loaded to the MyItem control. 
void IStateManager.LoadViewState(object savedState) 
{
   _message = (string)_viewstate["message"];
   if (savedState != null)
      ((IStateManager)_viewstate).LoadViewState(savedState);
}

[C++] 
// Implement the LoadViewState method. If the saved view state
// exists, the view-state value is loaded to the MyItem control.
void IStateManager::LoadViewState(Object* savedState) {
   _message = dynamic_cast<String*>(_viewstate->Item[S"message"]);
   if (savedState != 0)
      (dynamic_cast<IStateManager*>(_viewstate))->LoadViewState(savedState);
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

IStateManager Interface | IStateManager Members | System.Web.UI Namespace | Introduction to Web Forms State Management | StateBag | StateItem

Show:
© 2014 Microsoft