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 |