Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET SSRS
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:
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();
 
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 9-Jul-12 20:45pm
Comments
Sandeep Mewara at 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.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

This will not work using PartialPostback
 
Do post back for this Print Report (Excel/PDF) button by adding <asp:postbacktrigger xmlns:asp="#unknown"> or putting this button outside the UpdatePanel
 
Thanks
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

<asp:postbacktrigger xmlns:asp="#unknown">
 
errors with Validation (HTML 4.01): Element 'postbacktrigger' is not supported.
  Permalink  

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

  Print Answers RSS
0 Marcin Kozub 295
1 OriginalGriff 273
2 Richard MacCutchan 229
3 Praneet Nadkar 197
4 Sergey Alexandrovich Kryukov 190
0 OriginalGriff 7,913
1 Sergey Alexandrovich Kryukov 7,232
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,865


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 6 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100