Groups | Blog | Home
all groups > asp.net caching > january 2005 >

asp.net caching : caching and user controls


nmosafi NO[at]SPAM gmail.com
1/11/2005 4:12:31 AM
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
1/11/2005 11:54:14 AM
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
1/11/2005 2:09:49 PM
thanks for the help

Ollie Riches

[quoted text, click to view]

AddThis Social Bookmark Button