I have a Tab Container that has a reports tab. this tab allows the user to selecte the report enter the parameters and run the report. I also have a legacy COM object that creats the PDF/Excel report and then save's it to a directory on the server. the code below runs fine when not within a tab but when it is inside of a tab the file never is opened in the browser window.
Protected Sub btnGenerateOrders_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnGenerateOrders.Click
Dim tempReportType As String, tempCustID As String, tempStrID As String
Dim tempFromDate As String
Dim tempToDate As String
Dim tempLevelID1 As Integer
Dim tempStrCode1 As String = ""
If rptStartDate.Enabled Then
tempFromDate = rptStartDate.Text
tempToDate = rptEndDate.Text
Else
tempFromDate = "2000-01-01"
tempToDate = "2000-01-01"
End If
tempReportType = ddlAvailableReports.SelectedValue
tempStrID = "TEST" 'Server.HtmlEncode(Request.Cookies("smReferralCode").Value)
tempLevelID1 = Server.HtmlEncode(Request.Cookies("attuiAID").Value)
'tempStrCode1 = "5" 'Server.HtmlEncode(Request.Cookies("smCustomerType").Value)
Dim oReport As Object
Dim strPDFFilename As String
Dim oFileScripting As Object
Dim strReportPath As String
oReport = Server.CreateObject("AR_Provider_CloserCoupon_TEST.Exporter")
'oReport = Server.CreateObject("AR_Provider_CloserCoupon.Exporter")
'strReportPath = "C:\inetpub\wwwroot\@ATTAgentEntry\externalcloserCoupon\Reports"
'strReportPath = "C:\Inetpub\wwwroot\@TestSite\@ATTExternalClosercoupon2\Reports"
strReportPath = "C:\Inetpub\wwwroot\@TestSite\@ATTExternalClosercoupon\Reports"
'strReportPath = "C:\WINDOWS\system32\Reports"
oReport.ReportType = 2 'reportType.SelectedValue
oReport.Connect = "Provider=SQLOLEDB;Persist Security Info=False;User ID=CCCCC;password=BBBBB;Initial Catalog=JJJJ;Data Source=LLLLLL;"
oReport.FilePath = strReportPath
strPDFFilename = oReport.DataExport(CType(tempReportType, String), CType(tempStrID, String), CType(tempLevelID1, Integer), CType(tempFromDate, String), CType(tempToDate, String))
oFileScripting = CreateObject("Scripting.FileSystemObject")
Dim tempStrPDFFileName As String
tempStrPDFFileName = Mid(strPDFFilename, InStrRev(strPDFFilename, "\") + 1)
If oFileScripting.FileExists(strPDFFilename) = True Then
HttpContext.Current.Response.Clear()
HttpContext.Current.Response.Buffer = True
'Response.ContentType = "application/pdf"
Response.ContentType = "application/octet-stream"
Response.AddHeader("Content-Disposition", "attachment;filename=" & tempStrPDFFileName)
Dim vntStream
vntStream = oReport.ReadBinFile(strPDFFilename)
oFileScripting = CreateObject("Scripting.FileSystemObject")
oFileScripting.DeleteFile(strPDFFilename)
Response.BinaryWrite(vntStream)
Response.Flush()
Response.Close()
'oReport = Nothing
Else
'nothing
End If
End Sub
Any help would be a good thing.