caching and user controls

Discussion in 'ASP .Net' started by Ollie, Jan 11, 2005.

  1. Ollie

    Ollie Guest

    I am trying to use PartialCaching on a user control that has a image string
    property, I want cache different versions of the user control by the image
    string property but it fails to load the control when using the
    'Page.LoadControl' method.

    Pseudo code shown below:

    [PartialCaching(60, null, "ImageURL", null)]
    public class WizardIntro : System.Web.UI.WebControls.UserControl
    {
    protected System.Web.UI.WebControls.Image imWizardStage;
    protected System.Web.UI.WebControls.Literal ltWizardText;

    Public string ImageURL
    {
    get
    {
    return m_imageURL;
    }
    set
    {
    m_imageULR = value;
    }
    }

    private void Page_Load(object sender, System.EventArgs e)
    {
    ....
    ....
    }

    .....
    .....
    }


    Anyone have any ideas?


    Cheers

    Ollie Riches
     
    Ollie, Jan 11, 2005
    #1
    1. Advertising

  2. Ollie

    Guest

    You could have posted the code which was crashing.

    However I believe LoadControl will return an instance of
    System.Web.UI.PartialCachingControl rather than your own Control. You
    then need to reference the CachedControl property to pull out the
    control.. eg

    Control control = LoadControl ("MyControl.ascx");

    MyControl myControl;
    if (control is PartialCachingControl)
    {
    PartialCachingControl cacheControl = control as
    PartialCachingControl;
    myControl = (MyControl) cacheControl.CachedControl;
    }
    else
    {
    myControl = (MyControl) control;
    }
     
    , Jan 11, 2005
    #2
    1. Advertising

  3. Ollie

    Ollie Guest

    thanks for the help

    Ollie Riches

    <> wrote in message
    news:...
    > You could have posted the code which was crashing.
    >
    > However I believe LoadControl will return an instance of
    > System.Web.UI.PartialCachingControl rather than your own Control. You
    > then need to reference the CachedControl property to pull out the
    > control.. eg
    >
    > Control control = LoadControl ("MyControl.ascx");
    >
    > MyControl myControl;
    > if (control is PartialCachingControl)
    > {
    > PartialCachingControl cacheControl = control as
    > PartialCachingControl;
    > myControl = (MyControl) cacheControl.CachedControl;
    > }
    > else
    > {
    > myControl = (MyControl) control;
    > }
    >
     
    Ollie, Jan 11, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Teo Lachev
    Replies:
    0
    Views:
    396
    Teo Lachev
    Jul 1, 2003
  2. Hypo
    Replies:
    6
    Views:
    423
  3. Justice Gray
    Replies:
    0
    Views:
    379
    Justice Gray
    Oct 25, 2003
  4. Troy Simpson

    Fragment Caching inside page caching?

    Troy Simpson, Jan 19, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    806
    Troy Simpson
    Jan 19, 2004
  5. JimLad
    Replies:
    3
    Views:
    926
    JimLad
    Jan 21, 2010
Loading...

Share This Page