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:
- Retrieve a list of which controls to put on the page and the unique id of the content each control should display.
- For each control that should be created, call LoadControl and let the control know its unique id.
- 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!