Cache Controls loaded at Runtime

74 views Asked by At

My question is similar to Access to PartialCachingControl.CachedControl before Add it but since i cannot add the control to page before setting control attributes im still having problems

I have a UserControl with a public property called "Content" which i would like to cache. On the UserControl ive added:

<%@ OutputCache Duration="60" VaryByParam="none"  %>

Before adding the Cache Attribute i used to load the controls as followed

 public static Control DocumentWidget (System.Web.UI.Page currentPage, Comito.LokalPortalen.Domain.Entity.CMS.Content.Content content)
 {
    Comito.LokalPortalen.FrontEndShared.Controls.Document.Widget documentWidget = (FrontEndShared.Controls.Document.Widget)currentPage.LoadControl("/FrontEndShared/Controls/Document/Widget.ascx");
    if (documentWidget != null)
     {
        documentWidget.Content = content;
        return documentWidget;
     }
        return null;
}

I would now like to do something like :

PartialCachingControl documentWidget = (PartialCachingControl)currentPage.LoadControl("/FrontEndShared/Controls/Document/Widget.ascx");
if (documentWidget != null)
{
    System.Reflection.PropertyInfo cmsContent = documentWidget.GetType().GetProperty("Content");
    documentWidget.Content = content;
    return documentWidget;
}

Which fails with "PartialCachingControl doesnt contain a definition for "Content"

or like the solution supposed in Access to PartialCachingControl.CachedControl before Add it but since i cant add the control before setting attributes this doesnt Work.

Any solution

0

There are 0 answers