Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed

2 posts, 1 answers
  1. Ashbin
    Ashbin avatar
    4 posts
    Member since:
    Oct 2014

    Posted 08 Jul Link to this post

    I have a button inside RadAjaxPanel and i want to export it to the Excel Sheet, Below is the code i had written to do this task. If i removed the RadAjaxpanel then i can export the datatable into excel sheet. But when trying to export  it to Excel using radajax panel, I'm getting this error: Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed."

    <telerik:RadAjaxPanel ID="mainPanel" runat="server" LoadingPanelID="RadAjaxLoadingPanel">
            <table class="reportSearch">
                        <telerik:RadButton ID="btnExcelDetail" runat="server" Text="Excel" OnClick="btnExcelDetail_Click" ValidationGroup="SearchValidation" ClientEvents-OnRequestStart="requestStart">
                                <Icon PrimaryIconUrl="~/App_Themes/RnDThemes/images/insert_table_on.gif" PrimaryIconHeight="15" />
    <script type="text/javascript">
    function requestStart(sender, args) {               
                    if (args.get_eventTarget().indexOf("btnExcelDetail") >= 0)
    public void ExporttoExcel(DataTable table, string filename)
                HttpContext.Current.Response.Buffer = true;
                HttpContext.Current.Response.ContentType = "application/ms-excel";
                HttpContext.Current.Response.Write(@"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">");
                HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + filename + "");
                HttpContext.Current.Response.Charset = "utf-8";
                HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("windows-1250");
                HttpContext.Current.Response.Write("<TABLE border='1' bgColor='#ffffff' " +
                  "borderColor='#000000' cellSpacing='0' cellPadding='0' " +
                int columnscount = table.Columns.Count;
                for (int j = 0; j < columnscount; j++)
                    HttpContext.Current.Response.Write(@"<TD><B>" + table.Columns[j].ToString() + "</B></TD>");
                foreach (DataRow row in table.Rows)
                    for (int i = 0; i < table.Columns.Count; i++)
                        if (row[i].ToString().Trim().Length > 1 && row[i].ToString().Trim().StartsWith("0") && row[i].GetType().Name=="String")
                            HttpContext.Current.Response.Write("<TD style=\"mso-number-format:\\@\">");
                HttpContext.Current.Response.SuppressContent = true;
            catch (Exception) { }
  2. Answer
    Viktor Tachev
    Viktor Tachev avatar
    1438 posts

    Posted 11 Jul Link to this post


    If you are using the built-in export functionality for our controls it should work out of the box. Please ensure that you are using the latest version of the controls. The current release is 2016.2.607.

    Check out the following example that illustrates how you can export RadGrid to excel.

    In case you need to print the contents you can use the print feature:

    Viktor Tachev
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. DevCraft R3 2016 release webinar banner
Back to Top