caching and user controls

O

Ollie

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
 
N

nmosafi

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;
}
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top