Solved

asp.net view pdf in new window

Posted on 2014-09-29
7
451 Views
Last Modified: 2014-10-03
I am trying to get a pdf that is saved in the web directory ~/documents/test.pdf to open up in a new window.

I have hyperlinks that have different documents associated with them and I want them to open a new window with the PDF upon being clicked.

I am having much trouble figuring this out.

Doing this in asp.net c#
0
Comment
Question by:desiredforsome
  • 4
  • 3
7 Comments
 
LVL 18

Expert Comment

by:Jerry Miller
ID: 40350040
I am using something similar to this to open new windows, though I couldn't find my code that is doing this.

http://www.aspsnippets.com/Articles/Open-New-Window-from-Server-Side-Code-Behind-in-ASPNet-using-C-and-VBNet.aspx
0
 

Author Comment

by:desiredforsome
ID: 40350439
Hmm, does not seem to work well for me.
0
 
LVL 18

Expert Comment

by:Jerry Miller
ID: 40350578
When you say does not seem to work well, are you getting errors or what is it doing as you step through the code?


I found that I am using this in VB and it works fine.

ClientScript.RegisterStartupScript(Page.[GetType](), Nothing, "window.open('PrntMan.aspx', '_blank')", True)

I believe the C# equivalent would be:

ClientScript.RegisterStartupScript(this.GetType(), Nothing, "window.open('PrntMan.aspx', '_blank')", True)
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:desiredforsome
ID: 40350693
So Do I need to put the pdf in the web page?
0
 
LVL 18

Expert Comment

by:Jerry Miller
ID: 40350814
No, the link is only an example. Replace 'PrntMan.aspx' with your document name.


ClientScript.RegisterStartupScript(this.GetType(), Nothing, "window.open('~/documents/test.pdf', '_blank')", True)
0
 

Author Comment

by:desiredforsome
ID: 40350970
hmm it seems to work but i dont want the pdf location to be displayed in the url. Is there a way I can load it into a panel or some type of control ont he web page?

I was going to request parameters and then run a sql query against it o get the file location and open it in the backend.
0
 
LVL 18

Accepted Solution

by:
Jerry Miller earned 500 total points
ID: 40351060
You could try opening them in Adobe Reader instead of the browser:

http://stackoverflow.com/questions/9083047/open-pdf-in-adobe-reader-not-in-browser
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

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…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

863 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

25 Experts available now in Live!

Get 1:1 Help Now