?
Solved

Open a PDF from my C# .asp net site

Posted on 2009-04-03
3
Medium Priority
?
222 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 2000 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

770 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