Click here to Skip to main content
15,900,907 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello all,

As a solution to my previous post ""Files are not opening.[^]

I found this code which opens the pdf file that I want but what I want is to open this in a new page?

My code is;

C#
string fileToRenamePath = RMAConfig.PDFPath + "Return Documentation [ " + this.rmaObjSum.RMANum + " ]" + RMAConfig.Extension; 

// The valeu for fileToRenamePath here is : C:/RMA/Returns/Return Documentation[3232-32326].pdf

WebClient client = new WebClient();
        Byte[] buffer = client.DownloadData(fileToRenamePath);

        if (buffer != null)
        {
            Response.ContentType = "application/pdf";
            Response.AddHeader("content-length", buffer.Length.ToString());
            Response.BinaryWrite(buffer);
        }


This open the file in the current browser.
Posted

This might work.

C#
Response.Write("<script>window.open('file.pdf',target='new');</script>")


EDIT ================

Okay, I give up. Why was this 1-voted?
 
Share this answer
 
v2
Hi,

U can Use target=_blank property which will open it as new window

EG:

Response.Write("<script>window.open('http://www.google.com.hk/','_blank');</script>");



Happy Coding
 
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