IStateManager.LoadViewState(Object) 方法

定义

当由类实现时,将服务器控件以前保存的视图状态加载到控件。

public:
 void LoadViewState(System::Object ^ state);
public void LoadViewState (object state);
abstract member LoadViewState : obj -> unit
Public Sub LoadViewState (state As Object)

参数

state
Object

包含控件保存的视图状态值的 Object

示例

// 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);
}
' Implement the LoadViewState method. If the saved view state
' exists, the view-state value is loaded to the MyItem 
' control. 
Sub LoadViewState(ByVal 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

注解

此方法主要由 .NET Framework 基础结构使用,不应直接从代码中使用。 但是,控件开发人员可以重写此方法,以指定自定义服务器控件如何还原其视图状态。 有关详细信息,请参阅 ASP.NET 状态管理概述

适用于

另请参阅