Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 474
  • Last Modified:

asp.net view pdf in new window

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
desiredforsome
Asked:
desiredforsome
  • 4
  • 3
1 Solution
 
Jerry MillerCommented:
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
 
desiredforsomeAuthor Commented:
Hmm, does not seem to work well for me.
0
 
Jerry MillerCommented:
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
desiredforsomeAuthor Commented:
So Do I need to put the pdf in the web page?
0
 
Jerry MillerCommented:
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
 
desiredforsomeAuthor Commented:
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
 
Jerry MillerCommented:
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now