473,705 Members | 2,449 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

User Control, @OutputCache, and varying the cache by property value

Question:
If I have an ASP.NET User Control which defines/exposes a property that the
page can use to specify a mode or data subset for the control to use, is
there a way to tell the @OutputCache directive to vary its cache based on
that property value?

I.e., I have:

<my:control runat="server" id="mcOne" Flag="One" />
<my:control runat="server" id="mcTwo" Flag="Two" />

where Flag is a public property of the code-behind class (whose value
affects the display output), and I want the Flag="One" instance to
output-cache separately from the Flag="Two" instance.

So far, the control seems to output-cache only one version of the control,
and all successive displays of the control use that cached version,
regardless of the Flag attribute value.

Other notes:

The @OutputCache directive's VaryByParam attribute works only with GET and
POST values. (I did try VaryByParam="Fl ag" anyway, to no effect.)

Setting the @OutputCache directive's Shared attribute to "False" solves the
problem (by causing each usage of the control to cache separately), but has
the additional effect of requiring separate initial-loads and caches for
each page on which the control appears. Since I currently only have two or
three possible values of the Flag attribute, but these controls may appear
on many pages (and there is some work invovled in the initial load of the
data for this control), this is not ideal.

There doesn't seem to be any sort of VaryByProperty attribute for
@OutputCache (which surprises me). So...

Any other ideas?

- Tom Kiefer
thogek @ earthlink . net
Nov 18 '05 #1
6 2740
Have you looked at VaryByCustom?

--
venlig hilsen / with regards
anders borum
--
Nov 18 '05 #2
Yes, but I'm unclear on how that construct would be able to access anything
specific to the control being cached.

From
http://msdn.microsoft.com/library/en...utputCache.asp
and
http://msdn.microsoft.com/library/en...tringTopic.asp, I
see VaryByCustom allowing me to specify arbitrary rules that can act on the
HttpContext of the current request, but not on details within the control
itself (such as the value of a given property).

Unless I'm missing something....

- Tom Kiefer
thogek @ earthlink . net
"Anders Borum" <na@na.na> wrote in message
news:OE******** *****@TK2MSFTNG P12.phx.gbl...
Have you looked at VaryByCustom?

--
venlig hilsen / with regards
anders borum
--

Nov 18 '05 #3
I'm guessing from the lack of response that there's no ready way to do what
I'm looking for. :-(

If anyone from Microsoft is reading this, is there any indication that any
future versions of ASP.NET might support what I attempt to describe below?

- Tom Kiefer
thogek @ earthlink . net
"Tom Kiefer" <th****@earthli nk.net> wrote in message
news:OY******** *****@tk2msftng p13.phx.gbl...
Question:
If I have an ASP.NET User Control which defines/exposes a property that the page can use to specify a mode or data subset for the control to use, is
there a way to tell the @OutputCache directive to vary its cache based on
that property value?

I.e., I have:

<my:control runat="server" id="mcOne" Flag="One" />
<my:control runat="server" id="mcTwo" Flag="Two" />

where Flag is a public property of the code-behind class (whose value
affects the display output), and I want the Flag="One" instance to
output-cache separately from the Flag="Two" instance.

So far, the control seems to output-cache only one version of the control,
and all successive displays of the control use that cached version,
regardless of the Flag attribute value.

Other notes:

The @OutputCache directive's VaryByParam attribute works only with GET and
POST values. (I did try VaryByParam="Fl ag" anyway, to no effect.)

Setting the @OutputCache directive's Shared attribute to "False" solves the problem (by causing each usage of the control to cache separately), but has the additional effect of requiring separate initial-loads and caches for
each page on which the control appears. Since I currently only have two or three possible values of the Flag attribute, but these controls may appear
on many pages (and there is some work invovled in the initial load of the
data for this control), this is not ideal.

There doesn't seem to be any sort of VaryByProperty attribute for
@OutputCache (which surprises me). So...

Any other ideas?

- Tom Kiefer
thogek @ earthlink . net

Nov 18 '05 #4
Just a guess-- Have you looked at VaryByControl?

http://msdn.microsoft.com/library/de...parameters.asp

Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and confers no rights.
"Tom Kiefer" <th*******@eart hlinknot.net> wrote in message
news:OM******** ******@TK2MSFTN GP12.phx.gbl...
I'm guessing from the lack of response that there's no ready way to do what I'm looking for. :-(

If anyone from Microsoft is reading this, is there any indication that any
future versions of ASP.NET might support what I attempt to describe below?

- Tom Kiefer
thogek @ earthlink . net
"Tom Kiefer" <th****@earthli nk.net> wrote in message
news:OY******** *****@tk2msftng p13.phx.gbl...
Question:
If I have an ASP.NET User Control which defines/exposes a property that

the
page can use to specify a mode or data subset for the control to use, is
there a way to tell the @OutputCache directive to vary its cache based on that property value?

I.e., I have:

<my:control runat="server" id="mcOne" Flag="One" />
<my:control runat="server" id="mcTwo" Flag="Two" />

where Flag is a public property of the code-behind class (whose value
affects the display output), and I want the Flag="One" instance to
output-cache separately from the Flag="Two" instance.

So far, the control seems to output-cache only one version of the control, and all successive displays of the control use that cached version,
regardless of the Flag attribute value.

Other notes:

The @OutputCache directive's VaryByParam attribute works only with GET and POST values. (I did try VaryByParam="Fl ag" anyway, to no effect.)

Setting the @OutputCache directive's Shared attribute to "False" solves

the
problem (by causing each usage of the control to cache separately), but

has
the additional effect of requiring separate initial-loads and caches for
each page on which the control appears. Since I currently only have two

or
three possible values of the Flag attribute, but these controls may appear on many pages (and there is some work invovled in the initial load of the data for this control), this is not ideal.

There doesn't seem to be any sort of VaryByProperty attribute for
@OutputCache (which surprises me). So...

Any other ideas?

- Tom Kiefer
thogek @ earthlink . net


Nov 18 '05 #5
According to
http://msdn.microsoft.com/library/en...utputCache.asp
and
http://msdn.microsoft.com/library/en...parameters.asp,
this sounds like VaryByControl directs the control to tie its caching
conditions (in a way that is unclear to me) to those of child control whose
ID matches the value of the VaryByControl attribute -- not quite what I'm
looking for. (I suppose that, with some work, I might be able to kludge
this into what I want, but...)

I'm looking for a way to direct the control to cache itself separately for
each value of an arbitrary specified property of that control. Sort of a
VaryByProperty= "Flag" which would cause the control to be cached separately
for each value of the control's Flag property, as specified in the control's
HTML declaration (i.e., separately for Flag="One", Flag="Two", etc.).

I'm rather suprised that a VaryByProperty attribute of the @OutputCache
directive does not already exist (whether by that name or some other).

Again, unless I'm completely misunderstandin g....

- Tom Kiefer
thogek @ earthlink . net
"Eric Lawrence [MSFT]" <e_********@hot mail.com> wrote in message
news:uJ******** *****@tk2msftng p13.phx.gbl...
Just a guess-- Have you looked at VaryByControl?

http://msdn.microsoft.com/library/de...parameters.asp
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

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

"Tom Kiefer" <th*******@eart hlinknot.net> wrote in message
news:OM******** ******@TK2MSFTN GP12.phx.gbl...
I'm guessing from the lack of response that there's no ready way to do

what
I'm looking for. :-(

If anyone from Microsoft is reading this, is there any indication that any
future versions of ASP.NET might support what I attempt to describe below?
- Tom Kiefer
thogek @ earthlink . net
"Tom Kiefer" <th****@earthli nk.net> wrote in message
news:OY******** *****@tk2msftng p13.phx.gbl...
Question:
If I have an ASP.NET User Control which defines/exposes a property that
the
page can use to specify a mode or data subset for the control to use,
is there a way to tell the @OutputCache directive to vary its cache based

on that property value?

I.e., I have:

<my:control runat="server" id="mcOne" Flag="One" />
<my:control runat="server" id="mcTwo" Flag="Two" />

where Flag is a public property of the code-behind class (whose value
affects the display output), and I want the Flag="One" instance to
output-cache separately from the Flag="Two" instance.

So far, the control seems to output-cache only one version of the control, and all successive displays of the control use that cached version,
regardless of the Flag attribute value.

Other notes:

The @OutputCache directive's VaryByParam attribute works only with GET and POST values. (I did try VaryByParam="Fl ag" anyway, to no effect.)

Setting the @OutputCache directive's Shared attribute to "False" solves the
problem (by causing each usage of the control to cache separately),
but
has
the additional effect of requiring separate initial-loads and caches
for each page on which the control appears. Since I currently only have

two or
three possible values of the Flag attribute, but these controls may

appear on many pages (and there is some work invovled in the initial load of the data for this control), this is not ideal.

There doesn't seem to be any sort of VaryByProperty attribute for
@OutputCache (which surprises me). So...

Any other ideas?

- Tom Kiefer
thogek @ earthlink . net

Nov 18 '05 #6
I believe VaryByControl is what you're looking for. VayByControl should
accept the name of a property of that control and you'll get different cache
variations depending on the value set in the prop.

--
Corey O'Mara
MCSD.NET, MCT

"Tom Kiefer" <th*******@eart hlinknot.net> wrote in message
news:uk******** ******@TK2MSFTN GP10.phx.gbl...
According to
http://msdn.microsoft.com/library/en...utputCache.asp
and
http://msdn.microsoft.com/library/en...parameters.asp, this sounds like VaryByControl directs the control to tie its caching
conditions (in a way that is unclear to me) to those of child control whose ID matches the value of the VaryByControl attribute -- not quite what I'm
looking for. (I suppose that, with some work, I might be able to kludge
this into what I want, but...)

I'm looking for a way to direct the control to cache itself separately for
each value of an arbitrary specified property of that control. Sort of a
VaryByProperty= "Flag" which would cause the control to be cached separately for each value of the control's Flag property, as specified in the control's HTML declaration (i.e., separately for Flag="One", Flag="Two", etc.).

I'm rather suprised that a VaryByProperty attribute of the @OutputCache
directive does not already exist (whether by that name or some other).

Again, unless I'm completely misunderstandin g....

- Tom Kiefer
thogek @ earthlink . net
"Eric Lawrence [MSFT]" <e_********@hot mail.com> wrote in message
news:uJ******** *****@tk2msftng p13.phx.gbl...
Just a guess-- Have you looked at VaryByControl?

http://msdn.microsoft.com/library/de...parameters.asp

Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

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

rights.


"Tom Kiefer" <th*******@eart hlinknot.net> wrote in message
news:OM******** ******@TK2MSFTN GP12.phx.gbl...
I'm guessing from the lack of response that there's no ready way to do

what
I'm looking for. :-(

If anyone from Microsoft is reading this, is there any indication that any future versions of ASP.NET might support what I attempt to describe below?
- Tom Kiefer
thogek @ earthlink . net
"Tom Kiefer" <th****@earthli nk.net> wrote in message
news:OY******** *****@tk2msftng p13.phx.gbl...
> Question:
> If I have an ASP.NET User Control which defines/exposes a property that the
> page can use to specify a mode or data subset for the control to use, is
> there a way to tell the @OutputCache directive to vary its cache
based
on
> that property value?
>
> I.e., I have:
>
> <my:control runat="server" id="mcOne" Flag="One" />
> <my:control runat="server" id="mcTwo" Flag="Two" />
>
> where Flag is a public property of the code-behind class (whose
value > affects the display output), and I want the Flag="One" instance to
> output-cache separately from the Flag="Two" instance.
>
> So far, the control seems to output-cache only one version of the

control,
> and all successive displays of the control use that cached version,
> regardless of the Flag attribute value.
>
> Other notes:
>
> The @OutputCache directive's VaryByParam attribute works only with

GET and
> POST values. (I did try VaryByParam="Fl ag" anyway, to no effect.)
>
> Setting the @OutputCache directive's Shared attribute to "False" solves the
> problem (by causing each usage of the control to cache separately), but has
> the additional effect of requiring separate initial-loads and caches for > each page on which the control appears. Since I currently only have two or
> three possible values of the Flag attribute, but these controls may

appear
> on many pages (and there is some work invovled in the initial load

of the
> data for this control), this is not ideal.
>
> There doesn't seem to be any sort of VaryByProperty attribute for
> @OutputCache (which surprises me). So...
>
> Any other ideas?
>
> - Tom Kiefer
> thogek @ earthlink . net
>


Nov 18 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1528
by: Ivan D. | last post by:
I am making a User Control in visual basic, it contains a Picture Box. To allow the image to change at design time I added a property. When changing a *normal* PictureBox Image at design time in the properties window the delete key usually sets the Image to nothing, but when I tried this with my new property it did not work. I have a feeling something needs to be added to the property statement in order to accept Nothing for any
0
2090
by: skytouch_zyt | last post by:
I want to create a usercontrol and can set Click Event Function to it at desined-time,just as <myprefix:myLinkButton ... OnClick="ClickFunction" .../> the code how to write?any one help me thanks a lot
4
1361
by: Andrea Williams | last post by:
I'm trying to set up a user control and change some values from the aspx page, but I keep running into trouble. What I really would like to do is be able to set a Label.Text in the user control from an aspx page. If I open up a static method to set the Label in the code-behind of the user control(uc), then the code in the uc doesn't recognize that the label exists (only if the method is a static (shared) method). If I set up a private...
0
1043
by: Merkisson Jourhanssen | last post by:
I will be using LoadControl to add user control to aspx page at runtime. The user control hosts a server control (custom menu component) which requires property setting to display menu correctly: // In user control set property of custom menu to be value of myInt myCustomMenuServerControl.Orientation = myInt; Value of myInt must come from hosting aspx page. 1. In what event of hosting aspx page should I have LoadControl call? (Init?
1
1021
by: z. f. | last post by:
Hi, i'm writing a user control that lives inside a page, and i want to cache the output of the control. is it possible to cache the control's output using a property on the control. so that when the property is like the property of the cached data, the cached data is being outputed. if the property is not in the cache already, a new data is outputed.
0
1791
by: JJ_377 | last post by:
The following doesn't assign value to the dropdownlist - WHY? ___________________________________________________________________ In a user control (ascx named USACustomer) : Public Property State() As String Get Return Me.ddlState.SelectedValue End Get Set(ByVal Value As String)
8
2264
by: David Lozzi | last post by:
Howdy, I have a user control that is a report to display data. On the page the control is inserted in, I have filter options to filter the report. When I try to do something like this, nothing happens. dim filt as string ... build filter string... UserControl.ReportFilter = filt
3
1751
by: dave | last post by:
I am having trouble accessing a property set during run-time in a user control that I have built. The control is supposed to connect to a database using the path supplied by the developer at runtime. Any assistance would be greatly appreciated. The code is as follows: In the class I declared the private variable strDatabasePath public partial class UserControl1 : UserControl { //... other code private string strDatabasePath;
0
1836
by: Randy Gault | last post by:
I've created a very simple user control (just a label and a textbox). They are in their own assembly. Now I want to add a property to that control, so that when I add that control into a form in another assembly, that property will appear in the property list for that control at design time (in Visual Studio). The property is a resource string. There is a resource editor for images, so that the design-time user can set a bitmap...
0
8767
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8689
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9136
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7893
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6605
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4439
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4703
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3137
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2486
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.