Solved

Open a PDF from my C# .asp net site

Posted on 2009-04-03
3
221 Views
Last Modified: 2012-05-06
I have the exact path of the PDF file I want to open...I simply want to open it up in a new window...I want to do it from my click event
What is the best way to do it?  I was trying this but never got the syntax right to pass the pdf file to the script code... If the code below is the best way...how do I pass the page parameter in the line? Instead of it being hardcoded as 'YOURPAGE.pdf'?
Response.Write("<script type='text/javascript'>detailedresults=window.open('YOURPAGE.pdf');</script>")

I really don't want to add alot of javascript if there is another way.
0
Comment
Question by:cenetadmin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 16

Accepted Solution

by:
sunithnair earned 500 total points
ID: 24060521
Add this code in your click event
string pdfFile = "YOURPAGE.pdf";
ClientScript.RegisterStartupScript(this.GetType(), "openpdf", "window.open('" + pdfFile + "');", true);

Open in new window

0
 

Author Comment

by:cenetadmin
ID: 24060628
I tried it...I get 'Access is denied'...testing on my local laptop...do I need to set some security on the directory the file is in? maybe an IIS security issue?
0
 

Author Comment

by:cenetadmin
ID: 24060695
that was what it was...I created a virtual IIS directory and it worked. thanks for your help!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question