problem opening pdf files from aspx pages

Heppen

Member
Joined
Dec 23, 2005
Messages
9
Programming Experience
1-3
Hi,

I have a webapplic and now I want to open a pdf file in a new window. The pdf files are on a local drive on the webserver but when I open a file I get an error acces denied.

VB.NET:
[SIZE=2]
Response.Write("<script language=Javascript>window.open('" & Handtek & "','', 'Top=5px, Left=5px, edge=Raised, center=yes, help=no, resizable=yes,scrollbars=yes, status=yes,width=1000,height=600');</script>")
[/SIZE]

the variable Handtek contains the path to the file on the local disk

is there somebody what I forget...
 
Javascript runs on the client, not the server. so when the javascript runs to open the pdf file, the window will be looking for the file on the users local system, not the pdf on the server.

Instead, Handtek needs to be a URL that points to the PDF on the server. so for example, if your web site has the url http://www.mysite.com, then you could setup a virtual directory like http://www.mysite.com/pdfs/ and that virtual directory would map to the server folder c:\mysitepdfs , for example. so let's say there was a pdf in the c:\mysitepdfs named test.pdf... the Handtek value would be http://www.mysite.com/pdfs/test.pdf, NOT c:\mysitepdfs\test.pdf.

When the users window opens to http://www.mysite.com/pdfs/test.pdf, the file will be downloaded from the server to the client and open in the new window like you are looking to do.
 
Back
Top