Name
StateBag
Synopsis
Every control stores view state information in a StateBag
provided in the Control.ViewState
property, if you enabled the Control.EnableViewState
property.
View state includes information representing all properties of a control
or page and any custom items you added. Information is provided in a
key/value collection and is accessed much like the System.Web.SessionState.HttpSessionState
or System.Web.Caching.Cache
class. You can add a
value to the StateBag
collection like this: ViewState("NewObject") = dsNorthwind
.
The StateBag
can contain primitive types or
full-fledged serializable objects. When retrieving an object, you will have to cast it to the
correct type. Also note that you can enumerate through the StateBag
collection by using the StateItem
enumerator.
Public NotInheritable Class StateBag : Implements IStateManager, IDictionary, ICollection, IEnumerable ' Public Constructors Public Sub New() Public Sub New(ByVal ignoreCase As Boolean) ' Public Instance Properties Public ReadOnly Property Count As Integer Implements ICollection.Count Public Default Property Item( ByVal key As String) As Object Public ReadOnly Property Keys As ICollection Implements IDictionary.Keys Public ReadOnly Property Values As ICollection Implements IDictionary.Values ' Public Instance Methods Public Function Add(ByVal key As String, ByVal value As Object) As StateItem Public Sub Clear() Implements IDictionary.Clear Public Function GetEnumerator( ) As IDictionaryEnumerator Implements ...
Get ASP.NET in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.