HighTechTalks DotNet Forums  

fragment caching: determining if control has been cached (ASP.NET v1.1)

ASP.net Caching microsoft.public.dotnet.framework.aspnet.caching


Discuss fragment caching: determining if control has been cached (ASP.NET v1.1) in the ASP.net Caching forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
AT
 
Posts: n/a

Default fragment caching: determining if control has been cached (ASP.NET v1.1) - 11-17-2005 , 07:47 PM






I have a custom control which is programatically assigned to cache as
follows:

[PartialCaching(3600,"MyParam",null,null)]

The custom control is included in an .aspx page as such:

<tp:MyControl runat="server" id="objMyControl"/>

and there is a corresponding object variable declared in the page class
declaration:

MyControl objMyControl;

The dilemma I have is that I want to be able to modify a property of
the control programatically in the page load event handler:

objMyControl.MyProperty = "somevalue";

This works fine on the first page execution, when the control is not
cached; but once the control is cached the object is not instantiated
and therefore the property is inaccessible (object reference not set to
an instance of the object). This is by design, not a problem.

A try/catch block works, but is not especially elegant. My questions
are:

1) How (or where) exactly are controls cached, and is it possible to
reference the cached control programatically -- not to change it, but
just to determine if it is there?

2) If this is not possible, is there a reasonably straightforward
(non-kludgeworthy) method for allowing the property modification on the
first go and preventing it thereafter (until the cached item expires)?

Any input is much appreciated!

Tom McCoid


Reply With Quote
  #2  
Old   
AT
 
Posts: n/a

Default Re: fragment caching: determining if control has been cached (ASP.NET v1.1) - 11-22-2005 , 12:45 PM






This answers my question:

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

Simply test the for the existence of the control rather than the cached
control:

if ( objMyControl != null );


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.