asp.net网站显示主页内容不用担心

时间:2015-04-17 17:29:08

标签: asp.net slicknav

我正在尝试创建一个asp.net网站,并且正在使用记事本++,所以没有自动设置选项,例如来自visual studio。

我正在使用我想在整个网站上使用的母版页。

我遇到了很多问题,但最后有一个页面显示没有错误,但它现在没有显示母版页中的任何内容。

我包含了我的所有代码,希望有人可以向我解释为什么我的主页中的内容没有显示。我觉得我很亲密,但没有找到一个体面的教程来告诉我我需要做什么。

母版:

<asp:ContentPlaceHolder ID="CPH1" runat="server">

<HTML>

    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">

        <link rel="stylesheet" type="text/css" href="Style/main_Style.css">
        <link rel="stylesheet" type="text/css" href="Style/Responsive-Style.css">

        <link rel="stylesheet" href="Style/style.css">
        <link rel="stylesheet" href="Style/slicknav.css">
        <script src="http://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script>


        <link rel="stylesheet" href="Style/flexslider.css" type="text/css" media="screen" />

        <script src="Javascript/modernizr.js"></script>

    </head>

    <body>
        <div class="headerOutline">

            <div class="logo">
                <img class="omTechLogo" src="images/mainLogo.png"></img>
            </div>

            <div class="headerMenu">
                <ul id="menu">
                    <li class="headerMenuItem"><a class="menuText" href="Home.HTML">Home</a></li>
                    <li class="headerMenuItem"><a class="menuText" href="About.HTML">About</a></li>
                    <li class="headerMenuItem"><a class="menuText" href="Services.HTML">Services</a></li>
                    <li class="headerMenuItem"><a class="menuText" href="Portfolio.HTML">Portfolio</a></li>
                    <li class="headerMenuItem" id="headerMenuItem_last"><a class="menuText" href="Contact.HTML">Contact</a></li>
                </ul>

                <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
                <script src="JQuery/jquery.slicknav.js"></script>
                <script type="text/javascript">
                $(document).ready(function(){
                $('#menu').slicknav();
                });
                </script>

            </div>          

        </div>


        <div class="bodyOutline">

            <div class="flexslider" style="height:auto; min-height:150px;">
                <ul class="slides">
                    <li>
                    <img src="images/SliderImage1.jpg" />
                    </li>
                    <li>
                    <img src="images/SliderImage2.png" />
                    </li>
                    <li>
                    <img src="images/SliderImage3.jpg" />
                    </li>
                    <li>
                    <img src="images/SliderImage4.jpg" />
                    </li>
                </ul>
            </div>

  <script>window.jQuery || document.write('<script src="js/libs/jquery-1.7.min.js">\x3C/script>')</script>

  <script defer src="JQuery/jquery.flexslider.js"></script>

  <script type="text/javascript">
    $(function(){
      SyntaxHighlighter.all();
    });
    $(window).load(function(){
      $('.flexslider').flexslider({
        animation: "slide",
        start: function(slider){
          $('body').removeClass('loading');
        }
      });
    });
  </script>

        <div class="homepageBody">
</asp:ContentPlaceHolder>

<asp:ContentPlaceHolder ID="CPH2" runat="server">



</asp:ContentPlaceHolder>

<asp:ContentPlaceHolder ID="CPH3" runat="server">

        </div>



        </div>


        <div class="footerOutline">
            <div class="footerInfo"> 
                <a class="footerList" href="Home.HTML">Home</a>
                <a class="footerList" href="About.HTML">About</a>
                <a class="footerList" href="Services.HTML">Services</a>
                <a class="footerList_Last" href="Portfolio.HTML">Portfolio</a>  
                <a class="footerList_Last" href="Contact.HTML">Contact</a>                              
            <div class="socialMedia">
                <div class="socialMediaText">
                    <a href="http:\\www.linkedin.com"><img src="images/li.png"></img></a>
                    <a href="http:\\www.twitter.com"><img src="images/tw.png"></img></a>
                    <a href="http:\\www.youtube.com"><img src="images/yt.png"></img></a>
                    <a href="http:\\www.facebook.com"><img src="images/fb.png"></img></a>
                </div>


            </div>

        </div>

    </body>

</HTML>

</asp:ContentPlaceHolder>

和主页:

<%@ Page Language="C#" MasterPageFile="~/MasterPage/MasterPage.master" Title="Content Page"%>


<asp:Content ContentPlaceHolderId="CPH1" runat="server">
</asp:Content>

<asp:Content ContentPlaceHolderId="CPH2" runat="server">
TExt teX teXt

</asp:Content>

<asp:Content ContentPlaceHolderId="CPH3" runat="server">

</asp:Content>

我希望CPH1和CPH3中的内容显示在所有页面上,CPH2中的内容随每页显示

1 个答案:

答案 0 :(得分:1)

您的内容占位符ID = CPH3中有html标记。当您的页面膨胀时,它会将其内容呈现在该组件内部,以替换已存在的内容。在您的情况下,它将使用contentplaceholderid = CPH3呈现页面的空内容。

这是你的问题:

<asp:ContentPlaceHolder ID="CPH3" runat="server">

        </div>



        </div>


        <div class="footerOutline">
            <div class="footerInfo"> 
                <a class="footerList" href="Home.HTML">Home</a>
                <a class="footerList" href="About.HTML">About</a>
                <a class="footerList" href="Services.HTML">Services</a>
                <a class="footerList_Last" href="Portfolio.HTML">Portfolio</a>  
                <a class="footerList_Last" href="Contact.HTML">Contact</a>                              
            <div class="socialMedia">
                <div class="socialMediaText">
                    <a href="http:\\www.linkedin.com"><img src="images/li.png"></img></a>
                    <a href="http:\\www.twitter.com"><img src="images/tw.png"></img></a>
                    <a href="http:\\www.youtube.com"><img src="images/yt.png"></img></a>
                    <a href="http:\\www.facebook.com"><img src="images/fb.png"></img></a>
                </div>


            </div>

        </div>

    </body>

</HTML>

</asp:ContentPlaceHolder>

你基本上是用你的页脚杀死关闭的body和html标签。也许你试图这样做:?

    <div>
        <asp:ContentPlaceHolder ID="CPH3" runat="server">
        </asp:ContentPlaceHolder>
    </div>


    <div class="footerOutline">
        <div class="footerInfo"> 
            <a class="footerList" href="Home.HTML">Home</a>
            <a class="footerList" href="About.HTML">About</a>
            <a class="footerList" href="Services.HTML">Services</a>
            <a class="footerList_Last" href="Portfolio.HTML">Portfolio</a>  
            <a class="footerList_Last" href="Contact.HTML">Contact</a>                              
        <div class="socialMedia">
            <div class="socialMediaText">
                <a href="http:\\www.linkedin.com"><img src="images/li.png"></img></a>
                <a href="http:\\www.twitter.com"><img src="images/tw.png"></img></a>
                <a href="http:\\www.youtube.com"><img src="images/yt.png"></img></a>
                <a href="http:\\www.facebook.com"><img src="images/fb.png"></img></a>
            </div>
        </div>
    </div>
</body>