1

我有一个关于 ASP.NET 的视觉工作室的课程,并且在这个母版页上被难住了,请帮助我。我无法将默认页面链接到我不确定的母版页面

默认页面代码

<%@ 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>   
4

3 回答 3

1

考虑改变:

MasterPageFile="" 

到您的母版页的名称。通常:

MasterPageFile="~/MasterPage.master"
于 2012-10-11T10:58:07.037 回答
1

在你的 default.aspxMasterPageFile值是空的。因此,将其更改为您的母版页文件名。

MasterPageFile="<place master page path>"

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

提示:将光标放在“”( MasterPageFile="|" )之间,然后按 Ctrl + 空格键以获得智能,您将获得"Pick Master..."并单击以选择母版页。

于 2012-10-11T11:16:35.307 回答
1

首先在您的 MasterPageFile="~/YourMasterPage.master" 中给出 MasterPageFile 名称其次,您必须在内容占位符内编写代码..

于 2012-10-11T11:37:35.450 回答