Parameter.ViewState 属性

定义

获取状态信息的字典,这些信息使您可以在同一页的多个请求间保存和还原 Parameter 对象的视图状态。Gets a dictionary of state information that allows you to save and restore the view state of a Parameter object across multiple requests for the same page.

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

包含 StateBag 对象的视图状态信息的 Parameter 的实例。An instance of StateBag that contains the Parameter object's view-state information.

属性

示例

下面的代码示例演示如何使用视图状态对象将参数对象状态存储在扩展类的类中 ParameterThe following code example demonstrates how to use the view-state object to store parameter object state in a class that extends the Parameter class. 此代码示例是为类概述提供的更大示例的一部分 ParameterThis 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 服务器控件使用此属性(类的实例 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 input 元素。The values are then passed as a variable to an HTML hidden input element when subsequent requests are processed. 默认情况下,为所有服务器控件启用视图状态。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.

适用于

另请参阅