Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Friends.

am using Visual Studio 2010. and SSRS Reports with Report Viewer and i have afuctionality like export into PDF or Excel. when and using ajax update panel am getting below error.

"Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.
Details: Error parsing near '%PDF-1.3
1 0 obj
['."



my CS code sample:
C#
ReportViewer1.ShowCredentialPrompts = true;
ReportViewer1.ServerReport.ReportServerCredentials = new ReportServerNetworkCredentials();
ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
ReportViewer1.ServerReport.ReportServerUrl = new System.Uri(Convert.ToString(Session["REP_SERVER_URL"]));
ReportViewer1.ServerReport.ReportPath = Convert.ToString(Session["REP_SERVER_RPT_PATH"]) + "/OP_REPORTS/" + ReportName;
ReportViewer1.ServerReport.SetParameters(pr);
ReportViewer1.ServerReport.Refresh();
 ExportReport();


C#
private void ExportReport()
       {

           Byte[] bytes = null;
           string encoding;
           string mimeType = string.Empty;
           Warning[] warnings = null;
           string extension = string.Empty;

           string[] streamIDs = null;

           if (ExportTypeDdl.SelectedIndex == 1)
           {
               bytes = ReportViewer1.ServerReport.Render("Excel", Convert.ToString(ViewState["DeviceInfo"]), out mimeType, out encoding, out extension, out streamIDs, out warnings);
           }
           else
           {
               bytes = ReportViewer1.ServerReport.Render("pdf", Convert.ToString(ViewState["DeviceInfo"]), out mimeType, out encoding, out extension, out streamIDs, out warnings);
           }
           // Now that you have all the bytes representing the PDF report, buffer it and send it to the client.
           Response.Buffer = true;
           Response.Clear();
           Response.ContentType = mimeType;
           if (ReportNameDDl.SelectedIndex == 1)
           {
               Response.AddHeader("content-disposition", "attachment; filename=" + "Acknowledgement_Slip" + DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year + "-" + DateTime.Now.ToShortTimeString() + "." + extension);
           }
           else
           {
Response.AddHeader("content-disposition", "attachment; filename=" + "Loan_Schedule" + DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year + "-" +            DateTime.Now.ToShortTimeString() + "." + extension);
           }
            Response.BinaryWrite(bytes);
            Response.Flush(); // send it to the client to download


       }
Posted
Comments
Sandeep Mewara 10-Jul-12 1:55am    
Report Viewer version?
Did you Googled it? There was a known issue of ReportViewer with AJAX Update Panel.

Based on code, it's the playing around with Response object while AJAX update panel partial update is the reason.

<asp:postbacktrigger xmlns:asp="#unknown">

errors with Validation (HTML 4.01): Element 'postbacktrigger' is not supported.
 
Share this answer
 
This will not work using PartialPostback

Do post back for this Print Report (Excel/PDF) button by adding <asp:postbacktrigger xmlns:asp="#unknown"></asp:postbacktrigger> or putting this button outside the UpdatePanel

Thanks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900