StateBag::Item Property (String^)

 

Gets or sets the value of an item stored in the StateBag object.

Namespace:   System.Web.UI
Assembly:  System.Web (in System.Web.dll)

public:
property Object^ default[
	String^ key
] {
	Object^ get(String^ key);
	void set(String^ key, Object^ value);
}

Parameters

key
Type: System::String^

The key for the item.

Property Value

Type: System::Object^

The specified item in the StateBag object.

Using this member is the simplest way to save and retrieve view-state values for a control or a page.

If an item is not already stored in the StateBag object when you set this property, its key/value pair is added to the collection. If you set this property to null before the TrackViewState method is called on an item, it is removed from the StateBag object. Otherwise, when you set this property to null the key is saved to allow tracking of the item's view state.

The following code example demonstrates a property that saves its name and value as a key/value pair to the Control::ViewState property. The ViewState property is an instance of the StateBag class.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1
Return to top
Show: