Use a cache substitution widget
To substitute the cache for a particular widget, you create a custom cache substitution widget and place it on the page. The widget utilizes the ASP.NET cache substitution. You create a static method that registers with the ASP.NET implementation of cache substitution. Inside this method, you must render the content of the widget.
Create the widget markup
Create a User widget with the following markup:
Implement the code behind
If the widget, you want to substitute, inherits from
SimpleView, which in turn inherits from
System.Web.UI.WebControls.WebControl, you can override the
RenderContents(System.Web.UI.HtmlTextWriter writer) method. Inside, you call your own implementation for performing cache substitution.
When output cache is used on the page, you substitute it with the
DoPostCacheSubstitution() method by forming a dictionary of parameters and passing it to a
CacheSubstitutionWrapper.RenderMarkupDelegate that afterwards renders the correct markup.
IMPORTANT: Do not pass entire objects, such as a page, a control instance, property of the control, etc. This will cause serious memory leaks. When you need to pass a property value, you must use its string representation.
Following is a code sample of the code-behind file: