Ajax Triggers stop working after postback (Inside UserControl)

2 posts, 0 answers
  1. Robert
    Robert avatar
    8 posts
    Member since:
    Jul 2011

    Posted 21 Feb 2012 Link to this post

    I want to use RadGrid on many of my web app pages and I want the settings on all to be the same so I create a Grid in a UserControl. Below is my basic setup and issue:

    Site Master
    All pages share the same site master so in the site master I have a scriptManager and an RadAjaxManager. All the pages also share the same grid filters, start and end date, so there are two text boxes and a submit button, plus an export button.

    Content Pages
    Each content page only has the user control with a parameter that references a table in my database and in the code behind I have a list of the columns that I wish to have from that table.

    UserControl
    In my UserControl I build a RadGrid, create the NeedDataSource event, define export settings, and attach some javascript for certain functions. I also attach some ajaxSettings in the Page_Load event so the page does not do a full postback and some javascript clientEvents. This all works perfect until I export. Since the export requires a full postback, I have to turn off the ajax like so on the RequestStart event:

    if (args.get_eventTarget().indexOf("DownloadExcel") != -1) {
         args.set_enableAjax(false);
    }
    else {
         args.set_enableAjax(true);
    }

    Again this works and I get my export, but then the rest of the Ajax shuts down. If I change the date and submit, the grid does not rebind. I know the RequestStart and RequestEnd event still work because I put alerts in them, however, the grid does not refresh. And if I click export again, I receive this message:

    This webpage is not available

    The webpage at http://localhost:61219/pages/data/HourDetailed.aspx might be temporarily down or it may have moved permanently to a new web address.
    Error 103 (net::ERR_CONNECTION_ABORTED): Unknown error.

    Two things that I have tried
    • I recreated my grid without the UserControl by just using an asp:PlaceHolder instead and then transferred all my UserControl code to the page and everything works normal. No issues with postback.
    • I added a regular asp:Button to the UserControl that has UseSubmitBehavior="true" and another to the page to use as a manual postbacks. Both have the same exact symptoms as the export button. The problem appears to lie somewhere in the postback.

    I'm running out of things to try so if anyone has solved a similar issue, your help would be appreciated! 
  2. Robert
    Robert avatar
    8 posts
    Member since:
    Jul 2011

    Posted 21 Feb 2012 Link to this post

    Case Closed
    At some point when I was playing with optimization techniques I added this to my page:

    <%@ OutputCache Duration="600" VaryByParam="none" %>

    which was holding out the ajax on postbacks. Aye!!!!
Back to Top