Solved

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

Posted on 2010-09-10
6
528 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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Adobe Reader Viewing Issue 1 18
Hovering effect 9 29
Execute Stored Procedure for a set of values 5 26
Problem to page 4 23
*Adobe Acrobat 9 was used for this article.  Particular steps may vary depending on software versions. Adobe Acrobat has many, many variables that my be utilized to customize your forms for clarity and ease of use. The Form Editing Tool will be y…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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…

705 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

12 Experts available now in Live!

Get 1:1 Help Now