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 c#
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jerry MillerCommented:
I am using something similar to this to open new windows, though I couldn't find my code that is doing this.
desiredforsomeAuthor Commented:
Hmm, does not seem to work well for me.
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, "'PrntMan.aspx', '_blank')", True)

I believe the C# equivalent would be:

ClientScript.RegisterStartupScript(this.GetType(), Nothing, "'PrntMan.aspx', '_blank')", True)
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

desiredforsomeAuthor Commented:
So Do I need to put the pdf in the web page?
Jerry MillerCommented:
No, the link is only an example. Replace 'PrntMan.aspx' with your document name.

ClientScript.RegisterStartupScript(this.GetType(), Nothing, "'~/documents/test.pdf', '_blank')", True)
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.
Jerry MillerCommented:
You could try opening them in Adobe Reader instead of the browser:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.