Caching ascx control (2.0)

T

Tomasz J

Hello Developers,

Is it possible to vary ascx control cache base on that control's public
property.
My control has a public Color property, and I want to vary cache based this
property, rather than any particular contained control or query parameter.
Thank you for any hints.

Tomasz J
 
S

Steven Cheng[MSFT]

Hi Tomasz,

From your description, you'd like to cache an ascx userconttrol on your
page and also control the cache period through a certain property of the
control, correct?

So far based on my understanding, the usercontrol cache will support the
following cache conditions:

*VaryByCustom
*VaryByHeader
*VaryByParam
*VaryByControl

#@ OutputCache
http://msdn2.microsoft.com/en-us/library/hdxfb6cy(VS.71).aspx

#Caching Portions of an ASP.NET Page
http://msdn2.microsoft.com/en-us/library/h30h475z(VS.71).aspx

and for your scenario, I think you may consider store the Color property
into a certain control's property and set that control via the
"VaryByControl" condition. How do you think?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
 
T

Tomasz J

Thanks,

Well, Color was just an example - not the best one, since many controls have
this property.
Let's say that my ascx control has one custom property:

public string MyCustomProperty {get; set;}

and it contains Literal controls only.

I need to cache a different version of my control for every MyCustomProperty
value.

Tomasz
 
S

Steven Cheng[MSFT]

Thanks for your reply Tomasz,

Yes, the property on which you want to cache depend may vary, however,
since you'd like to adopt the built-in cache feature, you may try mappijng
your property value to one of those possible cache parameters(http get/get
value, Control property, ....).

Originally, I've thought about two means:

1. use an additional hidden TextBox control in the usercontrol(which
contains your certain custom property value) so that cache can rely on it.

2. You can programmatically use code to add some flag(your custom control's
value into cookie) and use the "VaryByCustom" option to programmatically
read cookie collection to determine how to cache, here is a article about
this:

http://codebetter.com/blogs/darrell.norton/archive/2004/05/04/12724.aspx

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
From: "Tomasz J" <[email protected]>
References: <[email protected]>
Subject: Re: Caching ascx control (2.0)
Date: Wed, 23 Jan 2008 12:19:04 +0100
 

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,995
Messages
2,570,231
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top