By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,335 Members | 2,718 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,335 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
something.

'This is a function in default.aspx code behind
Private Sub LoadProductsListing(ByVal sMenuID As String)
Try
Dim ctl As UserControl
ctl = LoadControl("Content/ProductListing.ascx")
'cellControlHolder is a table cell used to hold the user control
Me.cellControlHolder.Controls.Clear()
Dim ctlProd As ProductListing1 = ctl
'LoadMenu is a function in ProductListing1 codebehind that populates the
grid
ctlProd.LoadMenu(sMenuID)
Me.cellControlHolder.Controls.Add(ctlProd)
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?

--
mo*******@nospam.com
Nov 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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
http://msdn.microsoft.com/library/en...002.asp?frame=
true

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

Regards,

Steven Cheng
Microsoft Online Support

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

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
Nov 18 '05 #2

P: n/a

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.

Regards,

Steven Cheng
Microsoft Online Support

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

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.