【问题标题】:Open .pdf file in new browser Tab ASP.NET在新浏览器选项卡 ASP.NET 中打开 .pdf 文件
【发布时间】:2016-05-04 03:57:13
【问题描述】:

我有这个名为 StampaSingola 的函数:

Private Sub StampaSingola()
        Dim rpt As New rptLettera
        CType(rpt.DataSource, SqlDBDataSource).SQL = "Select * from vwLettere WHERE IdLettera IN (" & Request.QueryString("IdLettera") & ")"

    rpt.Run(False)

    If Not rpt Is Nothing Then
        Dim exp As New PdfExport
        ' Create a new memory stream that will hold the pdf output
        Dim memStream As New System.IO.MemoryStream
        ' Export the report to PDF:
        exp.Export(rpt.Document, memStream)
        exp.Dispose()
        exp = Nothing

        With Me.Context.Response
            .Buffer = True
            .ContentType = "application/pdf"
            .AddHeader("content-disposition", "attachment; filename=Archilet_Lettera_" & Request.QueryString("IdLettera") & ".pdf;")
            .BinaryWrite(memStream.ToArray)
            .Flush()
            .End()
        End With

        rpt.Document.Dispose()
        rpt.Dispose()
        rpt = Nothing
    End If
End Sub

如何在新的浏览器选项卡中打开 pdf? 谢谢

【问题讨论】:

    标签: asp.net tabs


    【解决方案1】:
    • 为下载“download.aspx”创建新页面
    • 将代码移至“download.aspx”页面中的 page_load 事件。
    • 在您的第一页的 button_click 事件中输入以下代码:

    protected void btnDownload_Click(object sender, EventArgs e) { Response.Write(string.Format("window.open('{0}','_blank');", "download.aspx")); }

    【讨论】:

      猜你喜欢
      • 2015-06-11
      • 2021-03-25
      • 2016-09-24
      • 2014-03-01
      • 2014-03-19
      • 2011-07-28
      • 1970-01-01
      • 2018-11-01
      相关资源
      最近更新 更多