How Do I Open a PDF File in a New Browser Instance?

I have an ASP.NET 2.0 web application using C# that allows users to locate a particular record and display the associated report file for that record.  The report files are stored as PDF files.  The application currently displays the PDF files in a window using the following code (this is a portion of the code from the GridView_SelectedIndexChanged method):

        Response.ContentType = "application/pdf";
        strDestFile = @"pdfs\" + oFile.Name;
        strDestFile = MapPath(strDestFile);
        Response.WriteFile(strDestFile);
        Response.End();

This displays the PDF correctly, but the specification for the software requires that each PDF file be launched in its own Browser instance, so the user does not need to hit the back button and can view multiple reports onscreen at the same time.

I need to know how to launch each PDF file as an independent browser instance.
LVL 1
wframsayAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ullfindsmitCommented:
use javascript to open a popup and then load the file in that window
0
ullfindsmitCommented:
use the code below
<script language="javascript">
 function showPDF( PDFName )
 {
  window.open( "http://myServer.com/MyFolder/" + PDFName );
 }
</script>
.
.
.
<a href="#" onclick="showPDF('123.pdf')">Open 123</a>

Open in new window

0
wframsayAuthor Commented:
I don't have an onclick() method to tie this to.
0
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

wframsayAuthor Commented:
Apologies for the terseness of my previous message.  What I'm trying to convey is that I want to use the GridView_SelectedIndexChange() event to a)determine which file to display and b) display the PDF file in a new browser instance.  I'm looking for a way to use the Response object to open the new window.
0
ullfindsmitCommented:
instead... you could simply use a template column and use the logic to show the file


<asp:gridview id="gvList" runat="server">
.
.
.
 
<itemtemplate>
 <a href='#' onclick="showPDF('<%# Eval("AAA") %>')">Click Here</a>
</itemtemplate>
 
.
.
.
.
 
</asp:gridview>

Open in new window

0
ullfindsmitCommented:
It seems I threw off the editor with the single and double quotes

<asp:gridview id="gvList" runat="server">
.
.
.
 
<itemtemplate>
 <a href='#' onclick="showPDF('<%# Eval("AAA") %>')">Click Here</a>
</itemtemplate>
 
.
.
.
.
 
</asp:gridview>
0
wframsayAuthor Commented:
The GridView is dynamically created and bound to a SqlDataReader, and I am using the AutoGenerateSelectButton property to generate the Select links for each PDF file.  I do not know how to make the modifications you are suggesting to this type of GridView - the columns for the GridView are dynamically created by a stored procedure call, not hard-coded.
0
wframsayAuthor Commented:
I ended up rewriting the grid view as a dynamically generated table so I could have multiple links on the page.  I am now opening the PDF files using a separate aspx page (with nothing on it).
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Browsers

From novice to tech pro — start learning today.