Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 24th, 2004, 02:55 PM
Authorized User
 
Join Date: Sep 2003
Location: , , .
Posts: 93
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to flyin
Default Common question, not so common answer?

Partial page caching is a technology that i am extremely excited about. I have kind of hit a road block when the content of the user control starts to become user specific.

Scenario.

Lets take a basic web page, a Top bar, Right bar, left bar, main section.
Top Bar: Static HTML, caached always
Right Bar: Top Users, Top Articles, and Recent Articles
Left Bar: login or manage account.
Main Section: DataSet stored in cache.

Problem:
In Manage Account, the user can specify which of these pieces will be rendered when they visit the page. So for instance, if i only want to view the Top Articles in the Right bar, i can specify so in the manage options page.
So, how do i do partial page caching and also complying with the users requests to customize a portion of the page? I understand the varybyparam deal, but i'm not sure if that's the best solution here.

This is a loaded question i know because you can simply create a UserProperties class that will know what this particular user wants in the business logic layer and then cache from there, but i'm wondering if there are better solutions that i can't see while i'm outside the box thinking!

thanks all

Flyin

Reply With Quote
  #2 (permalink)  
Old March 24th, 2004, 03:54 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi Flyin,

You can also take a look at VaryByCustom. That allows you to create, er, well, your own custom VaryBy settings....

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #3 (permalink)  
Old March 24th, 2004, 05:15 PM
Authorized User
 
Join Date: Sep 2003
Location: , , .
Posts: 93
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to flyin
Default

thank you Imar! i'll check it out

Reply With Quote
  #4 (permalink)  
Old March 24th, 2004, 05:39 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

The partial caching will allow you to cache the pieces of the page. i.e. you are going to cache the "top users" user control. Whether or not that control is visible on the page for a particular user is separate from the caching of that controls itself. Your main page will have an instance of that user control on it, and it will set the visibility of the control. But when the control is actually used, the runtime will determine if it should return the cached version based on the control's settings.

I did a test with some caching and I found some interesting things.

I created a simple user control that outputs the time to a label. I put a couple instances of the control on a page. Sure enough it cached. I set one control's visibility to false. The first time the control didn't show up. But on postback, it did show up with the properly cached output but it ignored my "visible=false". I found that when a control is loaded after it has been cached, its type comes back as "System.Web.UI.PartialCachingControl". So it seems that the control's viewstate information is not maintained (even its INITIAL setting making it invisible).

I also created a "show" and "hide" button on the page (not on the control) for each instance of the control. I set up the right code-behind class fields so I could set the control's properties in the button event handlers. When the control is cached, the page's member for it is not instantiated. This makes some sense related to the above problem of the visibility not behaving and type changing.

Then I added an instance of the control dynamically to the page instead of having the instance in the markup. This seemed to work ok. I could set the visibility of it with buttons in code-behind, and it maintained the visibility properly and also cached property. The only problem I found was that when I tried to add a SECOND instance programatically, I got a strange error saying that there are two controls with the same ID. This makes sense because the second instance of the control that comes back from "LoadControl()" would be cached.

You shouldn't have a problem if you are adding the controls programmatically and also setting their visibility programmatically based on the user preference settings. However, you can NOT expect to be able to interface with that control with a strongly typed variable of the user control class type. You would need to do some hearty checking of current types so you could tell if you can access the properties on it. The only members you can access are the members of "System.Web.UI.Control" as this is the base class from which you user control and the PartialCachingControl derive from.

Peter
------------------------------------------------------
Work smarter, not harder.
Reply With Quote
  #5 (permalink)  
Old March 24th, 2004, 06:05 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Interesting. Thanks for sharing this, Peter. Looks useful and intriguing.
When I find some time, I'll dig into this, and see if I can make some sense out of it. [The way the run-time handles this, not your story, of course ;)]

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #6 (permalink)  
Old March 24th, 2004, 06:50 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I put up the sample I created:
http://www.geekdork.com/samples/outp...utcaching.aspx
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Profile common bendjoe BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 13 October 12th, 2010 02:26 AM
Common value scandalous Excel VBA 1 December 21st, 2007 11:01 PM
RoleGroups common templates Tremmorkeep ASP.NET 2.0 Basics 1 May 11th, 2007 09:30 AM
common code austinf XSLT 3 May 3rd, 2006 09:38 AM
what is the common approach for it? thanks Robin1 Classic ASP Databases 6 September 11th, 2004 04:14 AM



All times are GMT -4. The time now is 11:08 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.