472,805 Members | 926 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,805 software developers and data experts.

How to cache different versions of a user control on the server

I have a user control that's used to display the products listing in the
main part of a page. This control is populated with a listing of products
from the database based on a category name passed into it via a function in
the code behind like this:
'Note, when we aren't looking at products, the product listing user control
gets switched out for a different user control such as aboutus.ascx or

'This is a function in default.aspx code behind
Private Sub LoadProductsListing(ByVal sMenuID As String)
Dim ctl As UserControl
ctl = LoadControl("Content/ProductListing.ascx")
'cellControlHolder is a table cell used to hold the user control
Dim ctlProd As ProductListing1 = ctl
'LoadMenu is a function in ProductListing1 codebehind that populates the
Catch ex As Exception
ErrLog(ex.Message, ex.StackTrace)
End Try
End Sub

So unlike a page that can have different versions cached based on the
parameters passed into the url, this user control get populated by calling a
function in its code behind from the parent page. Is there anyway to cache
a different version of this control for each product category?

Nov 18 '05 #1
2 1210
Hi Moondaddy,

From your description, your usercontrol has a certain member function which
can retrieve the data from database and construct the UserControl's actual
layout according to the input param, yes?

I'm afraid such situation is not suitable for using the asp.net 's caching
mechanism. Here are my understanding no this:
The asp.net's OutputCache(for both page or usercontrol) can depend on some
certain things such as request url's querystring , or some custom string
value , but all this dependence can be determined before the the page or
UserControl has been processed. For your scenario, the UserControl's cache
need to be dependent on a certain memeber function of itself. That means
its cache is will be determined after it's instanced and call certain
function. I don't think this suit the asp.net's buildin mechanism. Also,
here is a tech article describing the asp.net 's output caching mechanism.
You may have a look

#Page Output Caching, Part 1

Also, if you have any new ideas, please feel free to post here. Thanks.


Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no

Get Preview at ASP.NET whidbey
Nov 18 '05 #2

Hi Moondaddy,

Have you had a chance to check out the suggestions in my last reply or have
you got any further ideas on this issue? If you have anything unclear or if
there're anything else we can help, please feel free to post here. Thanks.


Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no

Get Preview at ASP.NET whidbey

Nov 18 '05 #3

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

Similar topics

by: Nadav | last post by:
Hi, I am new to WebControls, I have created a WebControl that is used to present an image, the image bing presented is created on runtime, each client side button click causes the image to...
by: Wolfgang Kaml | last post by:
I am not sure if this is more of an expert question, but I am sure that they are out there. I'd like to setup a general application or bin directory on my Win2003.Net Server that will hold some...
by: Tom Kiefer | last post by:
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...
by: moondaddy | last post by:
I have a products catalogue that I'm putting online and there will be between 20 to 50 different pages of products. Each page contains a datagrid of products for a given category. However, the...
by: sviau | last post by:
should cache-control be set to public or private on dynamic site. our content doesnt change for 24hrs, but because results from search pages vary so much, we cant cache the pages themselves. ...
by: Angel | last post by:
I am saving items in the cache in my code behind. By setting these items with an expiration are these items only available for the page its being set or throughout the application? My next question...
by: Tom.PesterDELETETHISSS | last post by:
Hi, I think this question requires an in depth understanding of how a browser cache works. I hope I can reach an expert here. I may have found a quirk in the asp.net documentation or I don't...
by: rrossney | last post by:
Please look at the "what I've already done" section of this message before responding to it: I believe that I've done everything that the people who experience this error are typically told to do....
by: =?Utf-8?B?QmlsbHkgWmhhbmc=?= | last post by:
Here is a user control on the page, how do I cache it by user? Currently I think we could put a server control for example ID:textusername in the asp.net page whose value is username, so we can...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: lllomh | last post by:
How does React native implement an English player?
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.