2012-10-11 72 views
1

我已經在一個asp.net的視覺工作室上了一堂課,並且難住在這個母版頁上,請幫助我。我不能默認頁面鏈接到母版頁我不知道無法鏈接default.aspx到母版頁請幫助。內容佔位符

默認頁面代碼

<%@ Page Title="" Language="C#" MasterPageFile="" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="AdrianASP2012.WebForm2" %> 

     <div> 
      <h2>Nulla luctus eleifend</h2> 
      <p>This is <strong>Greenness </strong>, a free, fully standards-compliant CSS template designed by <a href="http://www.freecsstemplates.org">FCT</a>. The photos in this template are from <a href="http://fotogrph.com/"> Fotogrph</a>. This free template is released under a <a href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attributions 3.0</a> license, so you are pretty much free to do whatever you want with it (even use it commercially) provided you keep the links in the footer intact. Aside from that, have fun with it :) </p> 
      <p>&nbsp;</p> 
      <p>Maecenas pede nisl, elementum eu, ornare ac, malesuada at, erat. Proin gravida orci porttitor enim accumsan lacinia. Donec condimentum, urna non molestie semper, ligula enim ornare nibh, quis laoreet eros quam eget ante. Aliquam libero. Vivamus nisl nibh, iaculis vitae, viverra sit amet, ullamcorper vitae, turpis. Aliquam erat volutpat. Vestibulum dui sem, pulvinar sed, imperdiet nec, iaculis nec, leo. Fusce odio. Etiam arcu dui, faucibus eget, placerat vel, sodales eget, orci. Donec ornare neque ac sem. Mauris aliquet. </p> 
      <p class="button-style"><a href="#">More Details</a></p> 
     </div> 

和母版頁身體部分是

<body> 
    <form id="form1" runat="server"> 
     <div id="header"> 
      <div id="logo"> 
       <h1><a href="#">Greenness</a></h1> 
      </div> 
      <div id="menu"> 
       <ul> 
        <li class="current_page_item"><a href="#" accesskey="1" title="">Homepage</a></li> 
        <li><a href="#" accesskey="2" title="">Our Clients</a></li> 
        <li><a href="#" accesskey="3" title="">About Us</a></li> 
        <li><a href="#" accesskey="4" title="">Careers</a></li> 
        <li><a href="#" accesskey="5" title="">Contact Us</a></li> 
       </ul> 
      </div> 
     </div> 
     <div id="banner-wrapper"> 
      <div id="banner"> 
       <img src="App_Themes/Theme1/images/pics01.jpg" width="1000" height="345" alt="" /> 
      </div> 
     </div> 
     <div id="page-wrapper"> 
      <div id="page"> 
       <div id="content"> 

        <!-- CONTENT PLACE HOLDER HERE --> 
        <asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server"></asp:ContentPlaceHolder> 


       </div> 
       <div id="sidebar"> 
        <h2>Maecenas lectus</h2> 
        <ul class="style1"> 
         <li class="first"> 
          <p><a href="#">Aliquam erat volutpat. Pellentesque tristique ante ut risus. Quisque dictum. Integer nisl risus, sagittis convallis, rutrum congue.</a></p> 
         </li> 
         <li> 
          <p><a href="#">Aliquam erat volutpat. Pellentesque tristique ante ut risus. Quisque dictum. Integer nisl risus, sagittis convallis, rutrum congue.</a></p> 
         </li> 
         <li> 
          <p><a href="#">Aliquam erat volutpat. Pellentesque tristique ante ut risus. Quisque dictum. Integer nisl risus, sagittis convallis, rutrum congue.</a></p> 
         </li> 
        </ul> 
       </div> 
      </div> 
     </div> 
     <div id="footer-wrapper"> 
      <div id="footer-content"> 
       <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"> 
       </asp:ContentPlaceHolder> 
       <div id="fbox2"> 
        <h2><span>Fusce ultrices</span> fringilla</h2> 
        <p> 
         <img src="App_Themes/Theme1/images/img05.jpg" width="320" height="150" alt="" /> 
        </p> 
        <p>Aliquam erat volutpat. Pellentesque tristique ante ut risus. Quisque dictum. Integer nisl risus, sagittis convallis, rutrum id, elementum congue, nibh. Donec leo, vivamus fermentum nibh in augue praesent a lacus at urna congue rutrum elementum congue.</p> 
        <p class="button-style"><a href="#">More Details</a></p> 
       </div> 
       <div id="fbox3"> 
        <h2><span>Mauris vulputate</span> scelerisque</h2> 
        <ul class="style3"> 
         <li class="first"> 
          <img src="App_Themes/Theme1/images/img02.jpg" width="78" height="78" alt=""> 
          <p>Nullam non wisi a sem eleifend. Donec mattis libero eget urna. </p> 
          <p class="posted">August 11, 2002 | (10) Comments</p> 
         </li> 
         <li> 
          <img src="App_Themes/Theme1/images/img03.jpg" width="78" height="78" alt=""> 
          <p>Nullam non wisi a sem eleifend. Donec mattis libero eget urna. </p> 
          <p class="posted">August 11, 2002 | (10) Comments</p> 
         </li> 
         <li> 
          <img src="App_Themes/Theme1/images/img04.jpg" width="78" height="78" alt=""> 
          <p>Nullam non wisi a sem eleifend. Donec mattis libero eget urna. </p> 
          <p class="posted">August 11, 2002 | (10) Comments</p> 
         </li> 
        </ul> 
       </div> 
      </div> 
     </div> 
     <div id="footer"> 
    </form> 
</body> 

回答

1

首先給出的MasterPageFile名字在你的MasterPageFile =「〜/ YourMasterPage.master」 其次,你必須編寫代碼的內容佔位裏面..

1

考慮更改:

MasterPageFile="" 

添加到您的母版頁的名稱。通常情況下:

MasterPageFile="~/MasterPage.master" 
1

在您的default.aspx MasterPageFile值爲空。因此將其更改爲您的主頁面文件名稱。

MasterPageFile="<place master page path>" 

MasterPageFile="~/Custom/UI/Templates/MasterPage.master" 

提示:地方「」(的MasterPageFile =「|」)之間的光標,然後按Ctrl +空格鍵爲intellisence,你會得到"Pick Master..."並單擊挑母版頁。