UserControl.CachePolicy Property
Gets a reference to a collection of caching parameters for this user control.
Assembly: System.Web (in System.Web.dll)
'Declaration <BrowsableAttribute(False)> _ Public ReadOnly Property CachePolicy As ControlCachePolicy
Property Value
Type: System.Web.UI.ControlCachePolicyA ControlCachePolicy containing properties that define the caching parameters for this UserControl.
The CachePolicy property defines the cache parameters for the instance of the UserControl class. The CachePolicy property is read-only; however, you can set the properties of the ControlCachePolicy object that it returns.
The CachePolicy property can not be set declaratively. It must be set programmatically.
The following code example demonstrates how to use the SupportsCaching property to determine whether the user control can be cached, and if so, sets the Duration property to cache the control for 10 seconds.
<%@ page language="VB"%> <%@ register src="SimpleControlvb.ascx" tagname="SimpleControl" tagprefix="uc1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) If SimpleControl1 IsNot Nothing Then Page.DataBind() If SimpleControl1.CachePolicy.SupportsCaching Then ' Set the cache duration to 10 seconds. SimpleControl1.CachePolicy.Duration = New TimeSpan(0, 0, 10) End If End If End Sub </script>
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.