开发者

Open Pdf in new tab

On Button Click I generate a PDF file a开发者_如何学Pythonnd then open it at client side with:

Response.ContentType = "application/pdf";
Response.TransmitFile(path);

This will show the pdf in the browser, but in the same tab. How can I open it in a new tab?


<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script  language=vbscript>
sub OpenInNewWindow()
    window.open("PDFContainer.aspx")
end sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Way 3</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <input type=button OnClick="OpenInNewWindow()"  value="Open in New Window"/>
        <br /><br />
        This time, we will open a new Internet Explorer Window and Show the PDF File directly in the IE
    </div>
    </form>
</body>
</html>


You cannot do this from the server side. It is a client side operation. see Create a new tab or window for a web page from ASP.NET

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜