本文介绍了如何在浏览器的不同选项卡中打开PDF文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用以下代码在浏览器中打开pdf文件,但是它在浏览器的同一选项卡中打开.我想在浏览器的其他选项卡中打开它.
可能吗?如果是这样,请帮助我..
-------------------------------------------------- -------------------
I am using the following code to open a pdf file in my browser.But it is opening in the same tab of the browser. I want open it in different tab of the browser.
Is it possible? If so please help me..
---------------------------------------------------------------------
protected void Button1_Click(object sender, EventArgs e)
{
string pdfPath = "D:\\Data\\Misc\\Time+registration.pdf";
WebClient client = new WebClient();
Byte[] buffer = client.DownloadData(pdfPath);
Response.ContentType = "application/pdf";
Response.AddHeader("content-length", buffer.Length.ToString());
Response.BinaryWrite(buffer);
}
-------------------------------------------------- ---------------------
预先感谢.
-----------------------------------------------------------------------
Thanks in advance.
推荐答案
//in Caller.aspx
//--------------
<script type="text/javascript">
function openwindow() {
window.open("Callee.aspx.aspx", "windowName", "height=500, width=700");
}
</script>
<asp:Button ID="Button1" runat="server" OnClientClick="openwindow()" Text="Button" />
//In Callee.aspx
//--------------
using System.Net;
protected void Page_Load(object sender, EventArgs e)
{
string pdfPath = "D:\\Data\\Misc\\Time+registration.pdf";
WebClient client = new WebClient();
Byte[] buffer = client.DownloadData(pdfPath);
Response.ContentType = "application/pdf";
Response.AddHeader("content-length", buffer.Length.ToString());
Response.BinaryWrite(buffer);
}
这篇关于如何在浏览器的不同选项卡中打开PDF文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!