共用方式為


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 狀態管理概觀

適用於

另請參閱