Cache.Item Property

Gets or sets the cache item at the specified key.

Namespace: System.Web.Caching
Assembly: System.Web (in system.web.dll)

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

/** @property */
public void set_Item (String key, Object value)

Not applicable.

Parameters

key

A String object that represents the key for the cache item.

Property Value

The specified cache item.

You can use this property to retrieve the value of a specified cache item, or to add an item and a key for it to the cache. Adding a cache item using the Item property is equivalent to calling the Cache.Insert method.

The following example uses the Item property to retrieve the value of a cached object associated with the Key1 key. It then uses the HttpResponse.Write method to write the value and introductory text and the B HTML element to a Web Forms page.

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

The following example demonstrates using this property to insert the value of a text box into the cache.

No code example is currently available or this language may not be supported.
private void cmdAdd_Click(Object objSender, EventArgs objArgs)
{
    if (!txtName.get_Text().Equals("")) {
        // Add this item to the cache.
        get_Cache().set_Item(txtName.get_Text(), txtValue.get_Text());
    }
} //cmdAdd_Click

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show: