?
Solved

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

Posted on 2010-09-10
6
Medium Priority
?
535 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
Independent Software Vendors: 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Update 21-May-2015: I temporarily removed the source code to make major changes to the program. Regards, Joe INTRODUCTION This article presents a solution to a question (http://www.experts-exchange.com/Programming/Installation/Q_28396542.html)…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Suggested Courses
Course of the Month7 days, 21 hours left to enroll

765 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