Caching dynamic controls in ASP.NET 1

Since the invention of partial caching in ASP.NET, we have been trying our best to implement it on our web pages. But without much luck. This post is a request, or I guess you could call it a “cry”, for help!

The problem is that we create all our controls dynamically, and each page can contain more than one instance of the same control (.ascx) but with different content.

Simply put, a page load is currently done like this:

  1. Retrieve a list of which controls to put on the page and the unique id of the content each control should display.
  2. For each control that should be created, call LoadControl and let the control know its unique id.
  3. Each control retrieves its data by using the unique id

Now, when trying to add partial caching to this control, the problem is that the controls are cached according to which page they’re on (or the query string used to get the page) and I just cannot figure out a way of caching two different instances of the same control. I mean, at the time of creation (LoadControl) I know which one I want, so it really should be theoretically possible, but I simply cannot find support for it in the API.

I’ve attached a simple test project that illustrates the problem. If you can find a nice solution, please, PLEASE let me know. I’d be in your debt!

One comment on “Caching dynamic controls in ASP.NET

  1. Jesper Sep 10,2007 21:10


    I had a look at the code-example quickly but couldn’t understand exactly what you are trying to achieve.

    But have a look at our post about similar subject. (in swedish)

    There are a few other links there that might be useful.

Comments are closed.