Solved

asp.net view pdf in new window

Posted on 2014-09-29
7
445 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
Comment Utility
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
Comment Utility
Hmm, does not seem to work well for me.
0
 
LVL 18

Expert Comment

by:Jerry Miller
Comment Utility
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
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.

 

Author Comment

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

Expert Comment

by:Jerry Miller
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

762 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

6 Experts available now in Live!

Get 1:1 Help Now