Provides programmatic access to an ASP.NET user control's output cache settings.
Assembly: System.Web (in System.Web.dll)
Gets or sets a value indicating whether fragment caching is enabled for the user control.
Gets or sets an instance of the CacheDependency class associated with the cached user control output.
Gets or sets the amount of time that cached items are to remain in the output cache.
Gets or sets the name of the output-cache provider that is associated with a control instance.
Gets a value indicating whether the user control supports caching.
Gets or sets a list of control identifiers to vary the cached output by.
Gets or sets a list of GET or POST parameter names to vary the cached output by.
Determines whether the specified object is equal to the current object.(Inherited from Object.)
Serves as the default hash function. (Inherited from Object.)
Instructs the BasePartialCachingControl control that wraps the user control to expire the cache entry at the specified date and time.
Instructs the BasePartialCachingControl control that wraps the user control to set the user control's cache entry to use sliding or absolute expiration.
Sets a list of custom strings that the output cache will use to vary the user control.
Returns a string that represents the current object.(Inherited from Object.)
The BasePartialCachingControl instance. The BasePartialCachingControl class represents a user control that has output caching enabled. When you access the BasePartialCachingControl::CachePolicy property of a PartialCachingControl control, you will always receive a valid object. However, if you access the UserControl::CachePolicy property of a UserControl control, you receive a valid object only if the user control is already wrapped by a BasePartialCachingControl control. If it is not wrapped, the object returned by the property will throw exceptions when you attempt to manipulate it because it does not have an associated BasePartialCachingControl. To determine whether a UserControl instance supports caching without generating exceptions, inspect the SupportsCaching property.class is used by developers in programmatic user control scenarios to specify output caching settings for user controls (.ascx files). ASP.NET embeds user controls within a
Using theclass is one of several ways you can enable output caching. The following list describes methods you can use to enable output caching:
Use the directive to enable output caching in declarative scenarios.
Use the PartialCachingAttribute attribute to enable caching for a user control in a code-behind file.
Use the BasePartialCachingControl instances that have been cache-enabled using one of the previous methods and dynamically loaded using the TemplateControl::LoadControl method. A instance can be successfully manipulated only between the Init and PreRender stages of the control life cycle. If you modify a object after the PreRender phase, ASP.NET throws an exception, because any changes made after the control is rendered cannot actually affect cache settings (a control is cached during the Render stage). Finally, a user control instance (and therefore its object) is only available for programmatic manipulation when it is actually rendered.class to specify cache settings in programmatic scenarios in which you are working with
The following code example demonstrates how a user control can be loaded dynamically and manipulated programmatically at run time. The PartialCachingAttribute attribute is applied to a user control named SimpleControl, which means the user control is wrapped by a PartialCachingControl control at run time. The SimpleControl object's caching settings can be programmatically manipulated through its associated object, which is available through a reference to the PartialCachingControl control that wraps it. In this example, the Duration property is examined during page initialization and changed using the SetSlidingExpiration and SetExpires methods if some conditions are met.
The following code example demonstrates using the SimpleControl user control from a Web Forms page. 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.
Available since 2.0
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.