ASP.NET UserControl Caching

Posted by Adam on Stack Overflow See other posts from Stack Overflow or by Adam
Published on 2010-06-12T14:27:25Z Indexed on 2010/06/12 14:32 UTC
Read the original article Hit count: 176

Filed under:
|
|

Hi,

This thing is driving me nuts. I have a UserControl that is called WebUserControl.

I need to cache this control, so I put the following in the WebUserControl.ascx:

<%@ OutputCache Duration="240" VaryByParam="FeedName" %>

Then I have the Default.aspx file in which I have:

      <div class="divInnerLeft" id="L1" runat="server">
            <uc1:WebUserControl FeedId="a1" ID="a1" runat="server" FeedName=""/>
       </div>
       <div class="divInnerMiddle" id="M1" runat="server">
            <uc1:WebUserControl FeedId="a3" ID="a3" runat="server" FeedName=""/>
       </div>

In the Page_Load event I set the FeedName property - according to the user preferences.

The problem is that after initially loading the page, the controls are generated OK. But then, in the Page_Load event they are not available again. So the a1 and a3 are null and I cannot set the FeedName for different user.

How to solve this?

Thanks!

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about caching