RadAjaxPanel - excluding control from async postback

4 posts, 0 answers
  1. Stan
    Stan avatar
    36 posts
    Member since:
    Feb 2011

    Posted 18 Mar 2011 Link to this post

    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
  2. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 23 Mar 2011 Link to this post

    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
  3. Stan
    Stan avatar
    36 posts
    Member since:
    Feb 2011

    Posted 23 Mar 2011 Link to this post

    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


  4. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 24 Mar 2011 Link to this post

    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
Back to Top