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

RadAjaxPanel - excluding control from async postback

3 Answers 259 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Stan
Top achievements
Rank 1
Stan asked on 18 Mar 2011, 10:54 PM
I need full postback when one of the buttons within RadAjaxPanel is clicked. I followed the documentation section "Exclude controls from ajaxifying" by registering postback on page load

ScriptManager1.RegisterPostBackControl(Button2);

This works, but only once. When the same or another button is clicked after the first time, nothing happens. No postbacks.

This may have something to do with SharePoint because the code runs fine if the control under ASP.NET, but once the control is deployed to SharePoint, postback occurs only once.

How can I troubleshoot this problem?

Thanks,

-Stan

3 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 23 Mar 2011, 02:24 PM
Hello Stan,

Could you please test the application by using regular asp UpdatePanel instead of RadAjaxPanel and let me know what the result is?

All the best,
Maria Ilieva
the Telerik team
0
Stan
Top achievements
Rank 1
answered on 23 Mar 2011, 06:41 PM
Strangely enough it is not related to RadAjaxPanel. It is a button that exports from RadGrid to Excel. There is one line of code behind it:

Grid.MasterTableView.ExportToExcel();

This works fine under ASP.Net development server, but as soon as control is deployed to SharePoint, the export works only once, second time page does not post back. Here is simplified page markup:

<telerik:RadTabStrip ID="TopTabStrip" runat="server" MultiPageID="MultiPage" Skin="Windows7" SelectedIndex="0"
     OnTabClick="OnTabClicked">
    <Tabs>
        <telerik:RadTab runat="server" Text="Shipments" />
        <telerik:RadTab runat="server" Text="Documents" />
    </Tabs>
</telerik:RadTabStrip>

<telerik:RadMultiPage ID="MultiPage" runat="server" SelectedIndex="0">
    <telerik:RadPageView ID="ItemsView" runat="server">           
        <div style="float:right">
            <asp:ImageButton ID="ExportToExcel" runat="server" ImageUrl="~/_layouts/images/excel_export.png"
                AlternateText="Export"
                OnClick="OnExportToExcel" />
        </div>
           
        <telerik:RadGrid id="ItemsGrid" runat="server" AutoGenerateColumns="false" Skin="Windows7"
             OnNeedDataSource="OnItemsGridNeedDataSource" AllowSorting="true" AllowPaging="true" PageSize="20">
            <MasterTableView ItemStyle-Wrap="false" HeaderStyle-Wrap="false">
                <Columns>                   
                </Columns>       
            </MasterTableView>
            <ExportSettings OpenInNewWindow="true" IgnorePaging="true" ExportOnlyData="true" FileName="ShipmentLineItems" />
        </telerik:RadGrid>
    </telerik:RadPageView>
           
-Stan


0
Maria Ilieva
Telerik team
answered on 24 Mar 2011, 04:16 PM
Hi Stan,

The cause for this behavior is that there is a flag (named _spFormOnSubmitCalled) in SharePoint which prevents double form submition. This flag is set when the form is submitted and clear when the response is received.
However when exporting the response is redirected and the page is not updated, thus the flag is not cleared and page's postbacks are blocked.

In order to workaround this behavior you should manually clear the flag when exporting.Find the code below for achieving this:

protected override void OnInit(EventArgs e)
{
    base.OnInit(e);
    Page.ClientScript.RegisterStartupScript(typeof(Web_Part1), this.ID, "_spOriginalFormAction = document.forms[0].action;_spSuppressFormOnSubmitWrapper=true;", true);
    if (this.Page.Form != null)
    {
        string formOnSubmitAtt = this.Page.Form.Attributes["onsubmit"];
        if (!string.IsNullOrEmpty(formOnSubmitAtt) && formOnSubmitAtt == "return _spFormOnSubmitWrapper();")
        {
            this.Page.Form.Attributes["onsubmit"] = "_spFormOnSubmitWrapper();";
        }
    }
}

You could also see the links below which elaborates on this matter:
http://www.faisalmb.com/blog/post/2010/01/28/Controls-not-functional-after-Export-to-Excel-or-Export-to-PDF-of-Telerik-in-Sharepoint-Application-page.aspx

All the best,
Maria Ilieva
the Telerik team
Tags
Ajax
Asked by
Stan
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Stan
Top achievements
Rank 1
Share this question
or