This is a migrated thread and some comments may be shown as answers.

reportbook export as PDF open in new window

1 Answer 50 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 23 Mar 2012, 10:38 AM
In Telerik 2012 Q1 i have created a reportbook. This reportbook needs to be opened in a new window. I cannot create this option. I'm using the following code:

void ExportToPDF(Telerik.Reporting.ReportBook reportToExport)
       {
           var deviceInfo = new Hashtable();
            
           ReportProcessor reportProcessor = new ReportProcessor();
           RenderingResult result = reportProcessor.RenderReport("PDF", reportToExport, deviceInfo);
         
           ////Create filename for PDF if saved
           //string fileName = result.DocumentName + ".pdf";
 
           Response.Clear();
           Response.ContentType = result.MimeType;
           Response.Cache.SetCacheability(HttpCacheability.Private);
           Response.Expires = -1;
           Response.Buffer = true;
 
           ////Code for automatically save PDF report
           //Response.AddHeader("Content-Disposition",
           //                   string.Format("{0};FileName=\"{1}\"",
           //                                 "attachment",
           //                                 fileName));
 
           
           Response.BinaryWrite(result.DocumentBytes);
           Response.End();
       }

This code is generated from several threads but I can't get it worked! It opens a PDF but in the same window!

Thanks in advance!


1 Answer, 1 is accepted

Sort by
0
prateek
Top achievements
Rank 1
answered on 17 Jul 2017, 08:47 AM

Hi You can do this simply by applying event -  OnClientClick="aspnetForm.target ='_blank';" 

 <asp:Button ID="exportPDF" runat="server" target="blank" Text="Export PDF" OnClientClick="aspnetForm.target ='_blank';" CssClass="btn btn-info" />

Tags
General Discussions
Asked by
Peter
Top achievements
Rank 1
Answers by
prateek
Top achievements
Rank 1
Share this question
or