Solved

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

Posted on 2010-09-10
6
530 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
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 perform Bates Numbering/Stamping of PDF documents using Power PDF Advanced, the newest product from the Document Imaging division of Nuance Communications. There are two editions of Power PDF — Standard and Advanced. Th…

770 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