473,503 Members | 1,648 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

control caching based on value

Hello. I'm trying to figure out how to cache a user control based on a given
value. Here's my scenario:

* I have 3 properties in a user control which I set programatically in my
aspx.vb page. I want to cache the control based on one of the properties.
It's called "Category"
* I get the category through a variety of ways - either through session or
the database. It's never in the querystring or a field on the screen.

I can get the control to cache the first Category value, but not any others.
The next time I get an "Object Not Found" exception when I try to set the
properties.

Any ideas how to do this?

Thanks for your help in advance!
--
Steve
Mar 19 '06 #1
2 1041
Are you using ASP.NET 2? If so, you should be able to use the
OutputCacheParameters.VaryByCustom Property to handle that scenario:

http://msdn2.microsoft.com/en-us/lib...om(VS.80).aspx

Ken
Microsoft MVP [ASP.NET]
"Steve" <sm*******@newsgroup.nospam> wrote in message
news:C8**********************************@microsof t.com...
Hello. I'm trying to figure out how to cache a user control based on a
given
value. Here's my scenario:

* I have 3 properties in a user control which I set programatically in my
aspx.vb page. I want to cache the control based on one of the properties.
It's called "Category"
* I get the category through a variety of ways - either through session or
the database. It's never in the querystring or a field on the screen.

I can get the control to cache the first Category value, but not any
others.
The next time I get an "Object Not Found" exception when I try to set the
properties.

Any ideas how to do this?

Thanks for your help in advance!
--
Steve

Mar 19 '06 #2
Thanks, Ken, for your reply. I am using 2.0. I still think I'm missing
something here. Here's how I have it coded..

My .ascx file:

<%@ OutputCache Duration="60" VaryByParam="None" VaryByCustom="category" %>

My aspx.vb file:

Response.Cache.SetVaryByCustom(category.ToString)

'Setup the main edit screen
myControl.Category = category.ToString
myControl.OtherProperty1 = "abc"
myControl.OtherProperty2 = def"

My Global.asax file:

Public Overrides Function GetVaryByCustomString(ByVal context As
System.Web.HttpContext, ByVal custom As String) As String
Return MyBase.GetVaryByCustomString(context, custom)
End Function
I always get and "Object reference not set to an instance of an object. "
error on the line myControl.Category = category.ToString.

What am I missing here?

Thanks for your help!

Steve

"Ken Cox - Microsoft MVP" wrote:
Are you using ASP.NET 2? If so, you should be able to use the
OutputCacheParameters.VaryByCustom Property to handle that scenario:

http://msdn2.microsoft.com/en-us/lib...om(VS.80).aspx

Ken
Microsoft MVP [ASP.NET]
"Steve" <sm*******@newsgroup.nospam> wrote in message
news:C8**********************************@microsof t.com...
Hello. I'm trying to figure out how to cache a user control based on a
given
value. Here's my scenario:

* I have 3 properties in a user control which I set programatically in my
aspx.vb page. I want to cache the control based on one of the properties.
It's called "Category"
* I get the category through a variety of ways - either through session or
the database. It's never in the querystring or a field on the screen.

I can get the control to cache the first Category value, but not any
others.
The next time I get an "Object Not Found" exception when I try to set the
properties.

Any ideas how to do this?

Thanks for your help in advance!
--
Steve


Mar 19 '06 #3

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

Similar topics

0
1230
by: Manish Jain | last post by:
I am trying to implement Partical Caching in a User Control that gets data from DB and populates a combo based on: 1) GroupKey : An int Property that is known for each call (say Source=10, Code=11...
0
1016
by: Mike Kingscott | last post by:
Meant to post in here as well... Hi there, I have a user control that brings back some links from a database based on a combination of querystring parms, so I'm using VaryByParm to...
6
2730
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...
4
6253
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. ...
4
2431
by: Josh Harris | last post by:
Here is my question: It is common to have many pieces of business logic encapsulated within asp.net user controls. This can be found in high visibility projects such as the iBuySpy portal from...
0
1306
by: Jeff Schaefer | last post by:
What I want to know is this: Is it possible to programmatically manipulate a custom property of a user control for which <%@ OutputCache ... > has been included? If so, then how? My brief code is...
3
2547
by: Joseph S. | last post by:
Is there a system available to do the following: consider an app of a few pages: page1.php: form1----->page3.php form2----->page4.php page2.php: form3----->page3.php form4----->page4.php
2
2087
by: =?Utf-8?B?SlA=?= | last post by:
Hi all. I'm having a problem with a postback issue and I think it's cache related. Here's my setup: I have a web site that has a signup section. This has simple things like name, age, birth...
12
2039
by: =?Utf-8?B?RGF2ZQ==?= | last post by:
I'm using ASP.Net with an UpdatePanel. When the screen is exercised via a Web Test, the Web Test shows that the AJAX scripts are downloaded for every partial post back. My impression was that...
0
7198
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,...
0
7072
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...
0
7319
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...
1
6979
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5570
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,...
1
4998
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...
0
3149
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1498
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 ...

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.