This is a migrated thread and some comments may be shown as answers.

Ajax Triggers stop working after postback (Inside UserControl)

1 Answer 100 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 21 Feb 2012, 07:53 PM
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! 

1 Answer, 1 is accepted

Sort by
0
Robert
Top achievements
Rank 1
answered on 22 Feb 2012, 03:18 AM
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!!!!
Tags
Ajax
Asked by
Robert
Top achievements
Rank 1
Answers by
Robert
Top achievements
Rank 1
Share this question
or