locked
view pdf file in browser RRS feed

  • Question

  • User884417960 posted

     Hi, I was hoping someone could tell me why when I click on a link to open a pdf document, nothing happens... I'm wanting it to open the pdf document in a browser window... Here is my code...

    <asp:HyperLink ID="employeeDocumentHyperLink1" runat="server" 
        NavigateUrl='<%# fullPath(DataBinder.Eval(Container.DataItem, "EmployeeCertificationDocument")) %>' 
        Text='<%# docCondition(DataBinder.Eval(Container.DataItem,"EmployeeCertificationDocument")) %>' Target="_blank"></asp:HyperLink>

    Here's what the link source code comes out to look like after I run it and view source... I don't see anything wrong with it... 

    <a id="ctl00_ctl00_MainContent_ChildContent1_certificationsRepeater_ctl01_employeeDocumentHyperLink1" href="C:\Program%20Files\Microsoft%20Visual%20Studio%209.0\Common7\IDE\employee_files_1\All%20Plans%20combined.pdf" target="_blank">Doc</a>

    Friday, March 20, 2009 9:24 AM

Answers

  • User-268709571 posted

    I am not sure what's wrong with your code, but I open the pdf using the following method and it works great:

     javascript function:

    function JSOpenPdf(URL)

    {

    day =
    new Date();

    id = day.getTime();

    eval(
    "page= window.open(URL.toString(), '" + id + "', 'left=20,top=20,width=700,height=500,toolbar=1,scrollbars=1,resizable=1');");

    }

    code behind:

    string strFilePathGrocery = "Files//MyPdf.pdf";

    imgHelpGrocer.Attributes.Add("onclick", "javascript:JSOpenPdf('" + strFilePathGrocery + "')");

    this is open a pdf on a image click.

    i hope it helps.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, March 20, 2009 12:15 PM
  • User-401694599 posted

    Can you try any one of these methods and see if they work?

    http://www.dotnetscraps.com/dotnetscraps/post/4-ways-to-send-a-PDF-file-to-the-IE-Client-in-ASPNET-20.aspx

    This will isolate the problem to your code or some other configuration.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, March 20, 2009 1:57 PM

All replies

  • User907890797 posted

     Forgive me for asking the obvious...but have you got Acrobat Reader installed?

    Friday, March 20, 2009 9:38 AM
  • User884417960 posted

    That's alright, but yes, I do have Adobe Acrobat Reader installed...

    Friday, March 20, 2009 9:41 AM
  • User-268709571 posted

    I am not sure what's wrong with your code, but I open the pdf using the following method and it works great:

     javascript function:

    function JSOpenPdf(URL)

    {

    day =
    new Date();

    id = day.getTime();

    eval(
    "page= window.open(URL.toString(), '" + id + "', 'left=20,top=20,width=700,height=500,toolbar=1,scrollbars=1,resizable=1');");

    }

    code behind:

    string strFilePathGrocery = "Files//MyPdf.pdf";

    imgHelpGrocer.Attributes.Add("onclick", "javascript:JSOpenPdf('" + strFilePathGrocery + "')");

    this is open a pdf on a image click.

    i hope it helps.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, March 20, 2009 12:15 PM
  • User-401694599 posted

    Can you try any one of these methods and see if they work?

    http://www.dotnetscraps.com/dotnetscraps/post/4-ways-to-send-a-PDF-file-to-the-IE-Client-in-ASPNET-20.aspx

    This will isolate the problem to your code or some other configuration.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, March 20, 2009 1:57 PM
  • User-401694599 posted

    Can you try any one of these methods and see if they work?

    http://www.dotnetscraps.com/dotnetscraps/post/4-ways-to-send-a-PDF-file-to-the-IE-Client-in-ASPNET-20.aspx

    This will isolate the problem to your code or some other configuration.

    Friday, March 20, 2009 2:04 PM
  • User-401694599 posted

    Can you try any one of these methods and see if they work?

    http://www.dotnetscraps.com/dotnetscraps/post/4-ways-to-send-a-PDF-file-to-the-IE-Client-in-ASPNET-20.aspx

    This will isolate the problem to your code or some other configuration.

    Friday, March 20, 2009 2:05 PM
  • User-401694599 posted

    Can you try any one of these methods and see if they work?

    http://www.dotnetscraps.com/dotnetscraps/post/4-ways-to-send-a-PDF-file-to-the-IE-Client-in-ASPNET-20.aspx

    This will isolate the problem to your code or some other configuration.

    Friday, March 20, 2009 2:07 PM