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

Async postback does POST then GET

3 Answers 124 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Jesse
Top achievements
Rank 1
Veteran
Jesse asked on 26 Nov 2013, 07:56 PM
I have a user control which contains a RadGrid and two RadDatePickers that let you choose the date range for the grid's data source. I've set up a submit button to trigger a partial postback to update the grid with data for the selected date parameters using a RadAjaxManager.

<telerik2012:RadAjaxManagerProxy ID="testAjaxManagerProxy" runat="server">
    <AjaxSettings>
        <telerik2012:AjaxSetting AjaxControlID="btnLoadHistory">
            <UpdatedControls>
                <telerik2012:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
            </UpdatedControls>
        </telerik2012:AjaxSetting>
    </AjaxSettings>
</telerik2012:RadAjaxManagerProxy>
 
    <asp:Panel ID="divSearch" runat="server" style="font: 9pt arial, tahoma">
        <span>From </span>
        <telerik2012:RadDatePicker ID="dpStartDate" runat="server">
        </telerik2012:RadDatePicker>
        <span>To </span>
        <telerik2012:RadDatePicker ID="dpEndDate" runat="server">
        </telerik2012:RadDatePicker>
        <asp:Button ID="btnLoadHistory" runat="server" Text="Go" CausesValidation="False"
            Style="vertical-align: bottom" />
         <asp:CompareValidator ID="CompareValidator1" runat="server"
            ErrorMessage="Invalid Date Range" ControlToCompare="dpEndDate"
            ControlToValidate="dpStartDate" Operator="LessThanEqual" Type="Date"></asp:CompareValidator>
    </asp:Panel>
 
    <telerik2012:RadGrid ID="RadGrid1" runat="server" ...

This user control is on a SharePoint 2007 page layout & master page. When debugging, I noticed the first time btnLoadHistory is pressed, the Page_Load event was occurring twice. The first time IsPostBack was true, the second time it was false. Using Fiddler, I found that when I press the button, it does the async postback (POST to the page) as you'd expect, when it gets the response, I see the RadGrid update, and then it immediately does a GET on the same page, hence the IsPostBack == false the second time. It only happens the first time after the page initially loads. After that I can click btnLoadHistory and only the expected postback occurs. Any ideas what's going on?

3 Answers, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 29 Nov 2013, 11:09 AM
Hi,

In case of master content you can follow the approach specified in this help topic and add the ajax settings programmatically:
http://www.telerik.com/help/aspnet-ajax/ajax-masterpage-update-everywhere.html


Regards,
Marin
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Jesse
Top achievements
Rank 1
Veteran
answered on 02 Dec 2013, 06:37 PM
Thanks for your response, Marin. I'm not following how that applies to the issue of a GET being submitted to the server after the postback. Can you please clarify? My wording may have been misleading as well. What I meant to say was the user control is on a SharePoint page layout, which uses a master page. The RadAjaxManager resides on the master page, hence the RadAjaxManagerProxy in use in the UserControl. However, the async request is initiated from a control within the UserControl and only the RadGrid within the UserControl is updated by the response. The link you posted seems to address how to communicate between master page and content page, which is not the case here. What I need to determine is how to eliminate the GET request that is occurring after the first postback completes.
0
Marin
Telerik team
answered on 03 Dec 2013, 10:00 AM
Hello,

Thank you for providing additional information on the issue.
Indeed a second GET request is not expected here, but it is not clear what might have caused it. You can check whether you have any server or client-side code that additionally makes a postback or an ajax request which can cause such issues. You can also test simpler scenarios to see if the same problem is observed first without any ajax on the page and then instead of RadAjaxManager and RadAjaxManagerProxy you can wrap the grid and date pickers in a RadAjaxPanel to see if this makes a change.
When using the RadAjaxManager in more complex scenarios of master page and user controls another option might also be to add the ajax settings programmatically in the Load event of the user control instead of using RadAjaxManagerProxy.

I hope this helps.

Kind Regards,
Marin
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Ajax
Asked by
Jesse
Top achievements
Rank 1
Veteran
Answers by
Marin
Telerik team
Jesse
Top achievements
Rank 1
Veteran
Share this question
or