Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2010-09-10
6
Medium Priority
?
540 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 33

Accepted Solution

by:
Todd Gerbert earned 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Inserting page numbers in Portable Document Files not only enhances manageability but also makes them look professional. With numbered pages, the file appears more organized and it becomes easier to search for a particular page. The size and the vol…
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 third video of the Xpdf series, we discuss and demonstrate the PDFtoText utility, which converts PDF files into plain text files. Download and install the software.: You may have already downloaded and installed the Xpdf tools while watching…
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …

610 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