open pdf within iframe in contentplaceholder

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lisles
    New Member
    • Jan 2010
    • 40

    open pdf within iframe in contentplaceholder

    im working with asp.net 2.0 and im using master pages.i have a link to a pdf file...when i click on the link i want the pdf to open within the contentplacehol der.im using iframe within the content placeholder.my master page code is below:

    Code:
    <%@ Master Language="C#" AutoEventWireup="true" CodeFile="jm.master.cs" Inherits="jm" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Prison Department, Goa</title>
        <link rel="stylesheet" href="style.css" type="text/css" charset="utf-8" />
    
        <script language="JavaScript" type="text/javascript">
    			var newBg;
    			function changeHl(strId)
    			{
    			   newBg = "images/HlImg/"+strId+".jpg";
    			   document.getElementById("imgHL").src = newBg;		  
    			}
        </script>
    
    </head>
    <body>
        <form id="mst" runat="server">
        
            <div id="wrapper">
                <div id="header">
                    <div style="color: #FFFFFF; font-family: 'Maiandra GD', 'Trebuchet MS', Tahoma, Verdana;">
                        <table id="tbl" width="100%">
                            <tr>
                                <td align="center" style="width: 145px">
                                    <img src="images/bg_charity1.jpg" alt="gov" style="width: 76px; height: 84px" /></td>
                                <td>
                                    <div style="font-size: 24px;">
                                        Inspector General of Prisons</div>
                                    <div style="font-size: 16px;">
                                        Government of Goa</div>
                                </td>
                            </tr>
                        </table>
                    </div>
                    <div id="navlist">
                        <ul id="Ul1">
                            <li><a id="hm" href="index.html">Home</a></li>
                            <li><a id="au" runat="server" href="AboutUs.aspx">About Us</a></li>
                            <li><a id="am" runat="server" href="Amenities.aspx">Amenities</a></li>
                            <li><a id="ne" runat="server" href="newsandevents.aspx">News & Events</a></li>
                            <li><a id="pr" runat="server" href="jailproducts.aspx">Products</a></li>
                            <li><a id="rti" runat="server" href="rghtoinfrmtn.aspx">R. T. I.</a></li>
                            <li><a id="cc" runat="server" href="remission.aspx">Remission</a></li>
                            <li><a id="fb" runat="server" href="Default2.aspx">Feedback</a></li>
                            <li><a id="cu" runat="server" href="contact.aspx">Contact Us</a></li>
                        </ul>
                    </div>
                </div>
                <div id="headline">
                    <div id="photo">
                        <div>
                            <img src="images/igp.gif" width="618" height="250" alt="Pic 1" />
                        </div>
                    </div>
                    <div id="search-news" style="height: 248px">
                       
                        <h2 class="downcast">
                            Quick Links</h2><br />
                        <div id="plussbullets">
                            <ul>
                                <li><a href="stats.aspx">
                                    Prison Statistics</a></li>
                                <li><a href="rightsandduties.aspx">
                                    Rights & Duties of Prisoners</a></li>
                                <li><a href="reformation.aspx">
                                    Jail Reformation</a></li>
                                    <li><a href="Citizen_new.pdf" target="myspot"> 
                                    Citizen's Charter</a></li>
                                <li><a href="listaddoff.aspx">
                                    List of area wise offices and Judicial Lock-Ups</a></li>
                                <li><a href="orgchart.aspx">
                                    Organisational Setup</a></li>
                            </ul>
                        </div>
                    </div>
                    <div class="clear">
                    </div>
                </div>
                <div id="body">
                    <asp:ContentPlaceHolder ID="cplMain" runat="server">
                    <iframe runat="server" id="myspot" name="myspot" width="75%" height="200">
    Sorry, your browser doesn't support iframes.
    </iframe> 
    
                    </asp:ContentPlaceHolder>
                    &nbsp;</div>
                <div class="clear">
                </div>
            </div>
            <div id="footer">
                <p>
                    &copy; 2009 all rights reserved.</p>
                <p>
                    Developed &amp; Maintained by Goa Electronics Limited
                </p>
                <p>
                    www.goaelectronics.co.in</p>
           
            </div>
        </form>
        
    </body>
    </html>

    i want the citizen_chart.p df to open within the iframe....the other links open in the content placeholder.eac h of the other pages reference the master page,so all the links are seen in every page.so whenever i click on the citizen charter lik the pdf should open in the iframe within the contentplacehol der....any idea how i can do it...plz help
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    accidentally posted in the ASP classic forum. Moved thread to the ASP.NET forum

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      You need to add some JavaScript to do this.

      During the JavaScript onclick event for the link you will set the "src" attribute of the iframe element to the URL of the pdf file that you want to display.

      -Frinny

      Comment

      • semomaniz
        Recognized Expert New Member
        • Oct 2007
        • 210

        #4
        A little google shall answer your question. There are lots and lots of example how to open a pdf within a frame .

        For all those people who find it more convenient to bother you with their question rather than to Google it for themselves.

        Comment

        Working...