Solved

Open a PDF from my C# .asp net site

Posted on 2009-04-03
3
215 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
  • 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

706 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now