UserControl.Cache Property
Gets the Cache object that is associated with the application that contains the user control.
[Visual Basic] Public ReadOnly Property Cache As Cache [C#] public Cache Cache {get;} [C++] public: __property Cache* get_Cache(); [JScript] public function get Cache() : Cache;
Property Value
The Cache object in which to store the user control's data.
Remarks
The Cache allows you to store data for later retrieval, and is shared across the application. The data that you store is independent of the current page or user session. Access data through this property to boost page or application performance if creating the data is slow. For more information about using the Cache, see Caching Application Data.
Example
[Visual Basic, C#, C++] The following example uses the Cache property to store the Text property value of a Label Web server control, txtValue, in the Cache object associated with the user control's application. It uses the Cache.this property to do so, assigning the item a key parameter value of txtName.Text.
[Visual Basic] Private Sub cmdAdd_Click(objSender As Object, objArgs As EventArgs) If txtName.Text <> "" Then ' Add this item to the cache. Cache(txtName.Text) = txtValue.Text End If End Sub [C#] private void cmdAdd_Click(Object objSender, EventArgs objArgs) { if (txtName.Text != "") { // Add this item to the cache. Cache[txtName.Text] = txtValue.Text; } } [C++] private: void cmdAdd_Click(Object* /*objSender*/, EventArgs* /*objArgs*/) { if (!txtName->Text->Equals(S"")) { // Add this item to the cache. Cache->Item[txtName->Text] = txtValue->Text; } }
[Visual Basic, C#, C++]
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family
See Also
UserControl Class | UserControl Members | System.Web.UI Namespace | Cache | Page.Cache