Solved

Open a PDF from my C# .asp net site

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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 …
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

914 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

17 Experts available now in Live!

Get 1:1 Help Now