BasePartialCachingControl::CachePolicy Property
Gets the ControlCachePolicy object that is associated with the wrapped user control.
Assembly: System.Web (in System.Web.dll)
Property Value
Type: System.Web.UI::ControlCachePolicyA ControlCachePolicy that stores output caching-related properties of the wrapped user control.
The CachePolicy property enables programmatic access to the ControlCachePolicy object associated with the user control contained by the BasePartialCachingControl instance. The ControlCachePolicy object can be programmatically manipulated to influence a user control's caching behavior and settings.
The following code example demonstrates how a user control can be loaded dynamically and manipulated programmatically at run time. This example has three parts:
A partial class, LogOnControl, that inherits from the UserControl base class and to which the PartialCachingAttribute attribute is applied.
A user control that is used with the LogOnControl partial class.
A Web Forms page that hosts the user control.
To run this example successfully, make sure the user control file (.ascx), its code-behind file (.cs or .vb), and the Web Forms page that hosts the user control (.aspx) are in the same directory.
The first part of the example demonstrates how the PartialCachingAttribute is applied to a user control named LogOnControl, which means the user control is wrapped by a PartialCachingControl control at run time. The LogOnControl object's caching settings can be programmatically manipulated through its associated ControlCachePolicy object, which is available through a reference to the PartialCachingControl that wraps it. In this example, caching settings are examined during page initialization and changed if some conditions are met.
The second part of the example shows a user control that is used with the previous example to demonstrate user control caching.
The third part of the example demonstrates using the LogOnControl user control from a Web Forms page.
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.