2011-08-17 102 views
4

打開PDF在按鈕單擊我生成一個PDF文件,然後在客戶端打開它:在新標籤頁

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

這將顯示在瀏覽器中的PDF格式,但在相同的標籤。我怎樣才能在新標籤中打開它?

+0

檢查[這](http://www.dotnetscraps.com/dotnetscraps/post/4-ways-to-send-a-PDF-file-to-the-IE-Client-in -ASPNET-20.aspx)博客文章。 – Vladimir

回答

4
<%@ 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> 
+0

+1僅僅爲了看到客戶端VBScript的難得經驗 –