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

4 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
    1488 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. UI for ASP.NET Ajax is Ready for VS 2017
  4. Al
    Al avatar
    203 posts
    Member since:
    Oct 2006

    Posted 25 Nov in reply to Viktor Tachev Link to this post

    Hi Viktor,

    Your answer refers to exporting a RadGrid to excel which is nice and easy but the OP is using an html table.

    I face the same error trying to use response.write to output a table to excel as above - is there something I can do to make this work?

  5. Viktor Tachev
    Viktor Tachev avatar
    1488 posts

    Posted 4 days and 10 hours ago Link to this post


    If you would like to specify the structure of the Excel file manually you can use the Export Infrastructure. Check out the following article that describes the functionality.

    When exporting the RadGrid you should use the InfrastructureExporting event and customize the Excel file.

    Viktor Tachev
    Telerik by Progress
    Telerik UI for ASP.NET AJAX is ready for Visual Studio 2017 RC! Learn more.
Back to Top