Provides a base class for all strongly typed collections that manage System.Web.UI.IStateManager objects.
See Also: StateManagedCollection Members
The System.Web.UI.StateManagedCollection class is the base class for all strongly typed collections that store System.Web.UI.IStateManager elements, including System.Web.UI.WebControls.DataControlFieldCollection, System.Web.UI.WebControls.ParameterCollection, System.Web.UI.WebControls.StyleCollection, System.Web.UI.WebControls.TreeNodeBindingCollection, and others. The System.Web.UI.StateManagedCollection collection manages its own state as well as the state of the elements it contains. Therefore, a call to System.Web.UI.StateManagedCollection.System.Web.UI.IStateManager.SaveViewState saves the state of the collection and the state of all the elements currently contained by the collection.
The most important methods to consider when deriving from the System.Web.UI.StateManagedCollection class are StateManagedCollection.CreateKnownType(int), StateManagedCollection.GetKnownTypes, StateManagedCollection.OnValidate(object), StateManagedCollection.SetDirty, and StateManagedCollection.SetDirtyObject(object). The StateManagedCollection.CreateKnownType(int) and StateManagedCollection.GetKnownTypes methods are used to store an index in view state for the type of a contained element. Storing an index rather than a fully qualified type name improves performance. The StateManagedCollection.OnValidate(object) method is called whenever elements of the collection are manipulated, and validates the elements according to business rules. Currently, the implementation of the StateManagedCollection.OnValidate(object) method prohibits null objects from being stored in the collection; however, you can override this method to define your own validation behavior in a derived type. The StateManagedCollection.SetDirty method forces the entire collection to be serialized to view state, rather than just serializing changes made to state since the last time it was loaded. The StateManagedCollection.SetDirtyObject(object) method is an abstract method you can implement to perform this same behavior at the element level.
System.Web.UI.StateManagedCollection stores assembly-qualified type names of the collection items in view state. A site visitor could decode the view state and retrieve the type name. If this scenario creates a security concern in your Web site, you can manually encrypt the type name before placing it in the view state.