Click here to Skip to main content
15,896,912 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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..
---------------------------------------------------------------------

C#
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.
Posted

hi
try to check following links:

http://forums.asp.net/t/1416989.aspx/1[^]
or
http://www.vbforums.com/showthread.php?t=640505[^]

regards
Robert
 
Share this answer
 
 
Share this answer
 
v2
My Sulution is as follows
------------------------
XML
//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);
    }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900