JavaScript Editor jscript editor     Web designer 



Main Page

You can cache multiple versions of a user control by simply declaring it in an .aspx file more than once. As with user controls that are not cached, you can include a cached user control in an ASP.NET page as many times as needed for your application. Unless you set the Shared property to true for the user control, multiple versions of the control output will be stored in the cache.

To cache multiple versions of a user control by using declarative attributes

  1. Using either the @ OutputCache directive in an .ascx file or the PartialCachingAttribute in the code-behind class, specify the output cache settings for the user control.

    The following @В OutputCache declaration will cache the control for 120 seconds:

    В CopyCode imageCopy Code
    <%@ OutputCache Duration="120" VaryByParam="None" %>
  2. Include multiple versions of the user control in a page, including the property you defined in the class as an attribute in the element. Make sure the property values are unique on the page.

    Simply including the @В OutputCache directive with a valid duration value in the .ascx file or setting the PartialCachingAttribute in the code-behind class allows varied cache output of a user control.

See Also



JavaScript Editor jscript editor     Web designer