In order to open two reports at the same time I have had to open two forms which then prompt the user to open or save the pdf report. Once the report is open I would like to close the form behind but so far have not had any luck.
I am using the following code to open the pdf.
Dim _reportManager As New ReportManager
Dim LocalReport As New LocalReport()
Dim reportType As String = "PDF"
Dim mimeType As String = ""
Dim encoding As String = ""
Dim fileNameExtension As String = ""
Dim deviceInfo As String = "<DeviceInfo>" + " <OutputFormat>PDF</OutputFormat>" + " <PageWidth>8.3in</PageWidth>" + _
" <PageHeight>11.7in</PageHeight>" + " <MarginTop>0.5in</MarginTop>" + " <MarginLeft>1in</MarginLeft>" + " <MarginRight>1in</MarginRight>" + _
" <MarginBottom>0.5in</MarginBottom>" + "</DeviceInfo>"
Dim warnings() As Warning = Nothing
Dim streams() As String = Nothing
Dim renderedBytes() As Byte
Dim CreatedDateFrom As String = Session("CreatedDateFrom").ToString()
Dim CreatedDateTo As String = Session("CreatedDateTo").ToString()
Dim ConfirmedDateFrom As String = Session("ConfirmedDateFrom").ToString()
Dim ConfirmedDateTo As String = Session("ConfirmedDateTo").ToString()
Dim ReceivedFrom As String = Session("ReceivedFrom").ToString()
Dim ReceivedTo As String = Session("ReceivedTo").ToString()
Dim _ds As DataSet = _reportManager.RunBusinessReport_ConfirmingBusinessRegistrationDetailsReport(0, True, IIf(CreatedDateFrom = "", Nothing, CreatedDateFrom), IIf(CreatedDateTo = "", Nothing, CreatedDateTo), IIf(ConfirmedDateFrom = "", Nothing, ConfirmedDateFrom), IIf(ConfirmedDateTo = "", Nothing, ConfirmedDateTo), IIf(ReceivedFrom = "", Nothing, ReceivedFrom), IIf(ReceivedTo = "", Nothing, ReceivedTo))
LocalReport.ReportPath = Server.MapPath("~/Reports/ReportRSTemplates/BusinessConfirmBusinessRegistrationDetails.rdlc")
LocalReport.DataSources.Add(New Microsoft.Reporting.WebForms.ReportDataSource("dsConfirmBusinessRegistrationDetails_msp_Report_Business_BusinessConfirmDetails_RS", _ds.Tables(0)))
renderedBytes = LocalReport.Render(reportType, deviceInfo, mimeType, encoding, fileNameExtension, streams, warnings)
Response.Clear()
Response.ContentType = mimeType
Response.AddHeader("content-disposition", "attachment; filename=CBRReport." + fileNameExtension)
Response.BinaryWrite(renderedBytes)
Response.End()
I tried to get the following code to run in Page_LoadComplete but the Response.End() stops all other code from running.
Dim strscript As String = "<script language=javascript>window.top.close();</script>"
If (Not ClientScript.IsStartupScriptRegistered("clientScript")) Then
ClientScript.RegisterStartupScript(Me.GetType(), "clientScript", strscript)
End If
Can anybody offer any advice?
Much appreciated.
I am using the following code to open the pdf.
Dim _reportManager As New ReportManager
Dim LocalReport As New LocalReport()
Dim reportType As String = "PDF"
Dim mimeType As String = ""
Dim encoding As String = ""
Dim fileNameExtension As String = ""
Dim deviceInfo As String = "<DeviceInfo>" + " <OutputFormat>PDF</OutputFormat>" + " <PageWidth>8.3in</PageWidth>" + _
" <PageHeight>11.7in</PageHeight>" + " <MarginTop>0.5in</MarginTop>" + " <MarginLeft>1in</MarginLeft>" + " <MarginRight>1in</MarginRight>" + _
" <MarginBottom>0.5in</MarginBottom>" + "</DeviceInfo>"
Dim warnings() As Warning = Nothing
Dim streams() As String = Nothing
Dim renderedBytes() As Byte
Dim CreatedDateFrom As String = Session("CreatedDateFrom").ToString()
Dim CreatedDateTo As String = Session("CreatedDateTo").ToString()
Dim ConfirmedDateFrom As String = Session("ConfirmedDateFrom").ToString()
Dim ConfirmedDateTo As String = Session("ConfirmedDateTo").ToString()
Dim ReceivedFrom As String = Session("ReceivedFrom").ToString()
Dim ReceivedTo As String = Session("ReceivedTo").ToString()
Dim _ds As DataSet = _reportManager.RunBusinessReport_ConfirmingBusinessRegistrationDetailsReport(0, True, IIf(CreatedDateFrom = "", Nothing, CreatedDateFrom), IIf(CreatedDateTo = "", Nothing, CreatedDateTo), IIf(ConfirmedDateFrom = "", Nothing, ConfirmedDateFrom), IIf(ConfirmedDateTo = "", Nothing, ConfirmedDateTo), IIf(ReceivedFrom = "", Nothing, ReceivedFrom), IIf(ReceivedTo = "", Nothing, ReceivedTo))
LocalReport.ReportPath = Server.MapPath("~/Reports/ReportRSTemplates/BusinessConfirmBusinessRegistrationDetails.rdlc")
LocalReport.DataSources.Add(New Microsoft.Reporting.WebForms.ReportDataSource("dsConfirmBusinessRegistrationDetails_msp_Report_Business_BusinessConfirmDetails_RS", _ds.Tables(0)))
renderedBytes = LocalReport.Render(reportType, deviceInfo, mimeType, encoding, fileNameExtension, streams, warnings)
Response.Clear()
Response.ContentType = mimeType
Response.AddHeader("content-disposition", "attachment; filename=CBRReport." + fileNameExtension)
Response.BinaryWrite(renderedBytes)
Response.End()
I tried to get the following code to run in Page_LoadComplete but the Response.End() stops all other code from running.
Dim strscript As String = "<script language=javascript>window.top.close();</script>"
If (Not ClientScript.IsStartupScriptRegistered("clientScript")) Then
ClientScript.RegisterStartupScript(Me.GetType(), "clientScript", strscript)
End If
Can anybody offer any advice?
Much appreciated.