这是我如何上传和打开PDF
文档的代码
<asp:LinkButton ID="linkButton" runat="server"
onclick="linkButton_Click">Show PDF</asp:LinkButton>
<telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server"
MultipleFileSelection="Disabled"
MaxFileInputsCount="1" Width="230px">
</telerik:RadAsyncUpload>
protected void linkButton_Click(object sender, EventArgs e)
{
if (RadAsyncUpload1.UploadedFiles.Count != 0)
{
byte[] _myfile = null;
UploadedFile _file = RadAsyncUpload1.UploadedFiles[0];
_myfile = new byte[_file.InputStream.Length];
_file.InputStream.Read(_myfile , 0, (int)_file.InputStream.Length);
Response.ClearHeaders();
Response.Clear();
Response.AddHeader("Content-Type", "application/pdf");
Response.AddHeader("Content-Length", _fileItenary.Length.ToString());
Response.AddHeader("Content-Disposition", "inline; filename=sample.pdf");
Response.BinaryWrite(_fileItenary);
Response.Flush();
Response.End();
}
}
此代码工作正常,可以在浏览器中显示我上传的 pdf。
但是,pdf 文件显示在同一页面(同一选项卡)中。
单击我的Show PDF
链接时,我想在新页面(新标签)中查看我的 pdf。
请帮助我,谢谢:)