Parameter.ViewState 屬性
定義
protected:
property System::Web::UI::StateBag ^ ViewState { System::Web::UI::StateBag ^ get(); };
[System.ComponentModel.Browsable(false)]
protected System.Web.UI.StateBag ViewState { get; }
[<System.ComponentModel.Browsable(false)>]
member this.ViewState : System.Web.UI.StateBag
Protected ReadOnly Property ViewState As StateBag
屬性值
StateBag 的執行個體,包含 Parameter 物件的檢視狀態資訊。An instance of StateBag that contains the Parameter object's view-state information.
- 屬性
範例
下列程式碼範例示範如何在擴充類別的類別中,使用 view-state 物件來儲存參數物件狀態 Parameter 。The following code example demonstrates how to use the view-state object to store parameter object state in a class that extends the Parameter class. 這個程式碼範例是針對類別總覽提供的較大範例的一部分 Parameter 。This code example is part of a larger example provided for the Parameter class overview.
// The DataValue can be any arbitrary object and is stored in ViewState.
public object DataValue {
get {
return ViewState["Value"];
}
set {
ViewState["Value"] = value;
}
}
' The DataValue can be any arbitrary object and is stored in ViewState.
Public Property DataValue() As Object
Get
Return ViewState("Value")
End Get
Set
ViewState("Value") = value
End Set
End Property
備註
參數的檢視狀態會累積其所有屬性值。A parameter's view state is the accumulation of all its property values. 若要在 HTTP 要求之間保留這些值,ASP.NET server 控制項會使用這個屬性(這是類別的實例 StateBag )來儲存屬性值。To preserve these values across HTTP requests, ASP.NET server controls use this property, which is an instance of the StateBag class, to store the property values. 然後,這些值會在處理後續要求時,以變數形式傳遞至 HTML hidden
輸入元素。The values are then passed as a variable to an HTML hidden
input element when subsequent requests are processed. 預設會為所有伺服器控制項啟用 [View state]。View state is enabled for all server controls by default.
如需有關字典以及如何使用它們的詳細資訊,請參閱 集合和資料結構。For more information about dictionaries and how to use them, see Collections and Data Structures.