Live Chat Icon For mobile
Live Chat Icon

How can I programatically invalidate the outputcache from a usercontrol

Platform: ASP.NET| Category: Output Caching

You could add a dependency to the output cached control, and change the dependency to evict the control. Here’s code to do that:

VB.NET


If TypeOf Parent Is System.Web.UI.BasePartialCachingControl Then
            	Cache('dependent') = 'dependent'
            	Dim dep As New CacheDependency(Nothing, New String() {'dependent'}) ’
            	CType(Parent, System.Web.UI.BasePartialCachingControl).Dependency = dep
End If

C#


if (Parent is System.Web.UI.BasePartialCachingControl) 
{ 
	Cache['dependent'] = 'dependent'; 
	CacheDependency dep = new CacheDependency(null, new string[] 'dependent'); 
	((System.Web.UI.BasePartialCachingControl)Parent).Dependency = dep; 
} 

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.