Update panel is not working if there is OutputCache directives in one of usercontrol in asp.net page

Last post 06-19-2006 7:08 AM by Luis Abreu. 1 replies.

Sort Posts:

  • Update panel is not working if there is OutputCache directives in one of usercontrol in asp.net page

    06-17-2006, 12:22 PM
    • Member
      201 point Member
    • SheoNarayan
    • Member since 12-23-2004, 11:30 PM
    • Hyderabad
    • Posts 76
    Hello guys,

    There is a user control in my page in the left panel that gives no. of new user in the website, I have used <%@ OutputCache Duration="3" Shared="true" VaryByParam="None" %> in the user control to Cache the output for 3 minutes.

    But when i use Outputcache directives then my gridview that is in UpdatePanel so without refresh sorting, paging can be done, starts NOT working, ie neither sorting, nor paging happens. However, when i remove the Outputcache directives from the user control, the same page starts working fine.

    Is there any solution, so i can use Outputcache directives and still my Gridview will function well.

    Thanks
    Sheo


    --
    Thanks with regards,
    Sheo Narayan
    http://www.dotnetfunda.com/profile/SheoNarayan.aspx

    Please "Mark as Answer", if this helped.
  • Re: Update panel is not working if there is OutputCache directives in one of usercontrol in asp.net page

    06-19-2006, 7:08 AM
    Answer
    • All-Star
      25,662 point All-Star
    • Luis Abreu
    • Member since 02-12-2005, 6:22 AM
    • Madeira [Portugal]
    • Posts 5,368
    • TrustedFriends-MVPs

    hello.

    yep, the caching is causing problems with the partial rendering of the scriptmanager control. the problem is that during the callback, if event validation is enabled, all the controls will be rendered (including your user control). since you've cached the user control, it'll be the responsibility of one of the derived classes od basepartialcachincontrol to render its content. unfortunatelly, the scriptmanager uses a dummy text writer which doesn't have a constructor that receives a textwriter, you'll get that exception when that classes renders the user control maintained in the cache.

    so, this is definitly a bug.

    to solve it, you have to set the enableeventvalidation to false on the page directive (which might not be a good thing!)

    --
    Regards,
    Luis Abreu
    email: labreu_at_gmail.com
    EN blog:http://msmvps.com/blogs/luisabreu
Page 1 of 1 (2 items)