Solved

Open PDF in the New window using C# in ASP.NET application

Posted on 2010-09-10
6
529 Views
Last Modified: 2012-05-10
Hi,
   i am trying to open a pdf document from the server.. when i click the button it opens the PDF in the web page.. i need to open it in the New window.. can anyone share the C# code.. thanks..
0
Comment
Question by:gautam_reddyc
  • 4
  • 2
6 Comments
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 33650175
Make the target of the link "_blank"
0
 

Author Comment

by:gautam_reddyc
ID: 33650247
its not the hyperlink.. we cannot open pdf in another winow using target="_blank".. thanks for trying though
0
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 33650347
You need to be much more specific with your question then. Is this an ASP.Net, WPF, or WinForms? How are you opening the PDF now? Can you post your code?
0
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.

 
LVL 33

Accepted Solution

by:
Todd Gerbert earned 500 total points
ID: 33650408
You're using an <asp:Button>?  Set a "window.open()..." in the OnClientClick, or set a variable in code-behind to fire a client-side script.
<%@ Page Language="C#" %>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



<script runat="server">

	

	private string openPdf = String.Empty;



	private void pdfButton_Click(object sender, EventArgs e)

	{

		openPdf = "true";

	}

</script>



<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title></title>

	<script language="javascript" type="text/javascript">

		function OnLoad() {

			if ("<%=openPdf %>" == "true")

				window.open("http://www.google.com");

		}

	</script>

</head>

<body onload="OnLoad()">

    <form id="form1" runat="server">

		<asp:Button ID="pdfButton" runat="server" Text="Open PDF" OnClick="pdfButton_Click" />

    </form>

</body>

</html>

Open in new window

0
 

Author Closing Comment

by:gautam_reddyc
ID: 33651076
thanks a ton..
0
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 33651764
Glad to help, maybe next time I'll actually read your question before answering. ;)
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

*Adobe Acrobat 9 was used for this article. Particular steps may vary depending on software versions. 1. Create a framework of your form in Word, leaving space where you’d ultimately like the Adobe fields to appear.  (Note: I use the blank lines …
The Adobe PDF proprietary file format is recognized as secure and formulated. But these PDF files are also prone to corruption and any external threat like virus attacks, improper storage can hit PDF file integrity.This type of damages can make cruc…
In this second video of the Xpdf series, we discuss and demonstrate the PDFimages utility, which, in a single command, is able to extract all the images from a PDF file and save each one in a separate image file (PBM, PPM, or JPG). Download and inst…
Sometimes we receive PDF files that are in the wrong orientation. They may be sideways or even upside down. This most commonly happens with scanned or faxed documents. It is possible to rotate the view of these PDFs with the free Adobe Reader produc…

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