Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Caching / November 2005

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
hamstak@yahoo.com - 18 Nov 2005 00:47 GMT
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
hamstak@yahoo.com - 22 Nov 2005 17:45 GMT
This answers my question:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cp
concachingportionsofaspnetpage.asp


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

if ( objMyControl != null );

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.