Hi,
I have been searching all over the net for a way to clear the contents of the outputcache declared on a usercontrol (so that it'll be regenerated even before the cache expires) but to no avail. Unfortunately Response.RemoveOutputCacheItem() does not work with usercontrols. I came across a very old thread on this forum here:
http://forums.asp.net/1/413989/ShowThread.aspx
which might be just the thing I need but I am unable to get the code samples there to work properly. I cannot get the code samples here to work either.
http://www.syncfusion.com/FAQ/aspnet/WEB_c25c.aspx
For my case the cache simply refuses to clear. If I dynamically load the usercontrol, it appears to work but I have server controls there like <asp:dropdownlist> which I further script via clientside Javascript, and if dynamically loaded, their clientside IDs gets messed up.
I was hoping someone could help me adapt mvola's example which supposedly can work with usercontrols declared within an aspx page (rather than loading them dynamically). The code snippet was given as:
<%@ Page %>
<%@ Register tagprefix="mycontrol" tagname="control" src="cachedcontrol.ascx" %>
<script language="c#">
void Page_Load()
{
// have to check whether the control is instantiated (it wont be for all requests for which it is satisfied from cache
if (theCachedControl!=null)
{
// get the parent partial caching wrapper
StaticPartialCachingControl pcc = (StaticPartialCachingControl)theCachedControl.Parent;
// create and add desired dependency
pcc.Dependency = new CacheDependency(...);
}
}
</script>
<mycontrol:control id="<span" class="st">"theCachedControl" runat="server" />
Tried to convert it to a codebehind version but it didn't work tho it compiled without errors.
Any help would be very much appreciated. Thanks in advance.
Regards
CK