Solved

Open a PDF from my C# .asp net site

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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!
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

730 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