嵌套母板页简单应用

来源:互联网 发布:小型学校网络设计 编辑:程序博客网 时间:2024/06/14 03:20
MainMaster.master:<%@ Master Language="C#" CodeFile="MainMaster.master.cs" Inherits="MainMaster" %><!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 runat="server">    <title>主母版页</title>    <%--<asp:ContentPlaceHolder id="head" runat="server">    </asp:ContentPlaceHolder>--%></head><body>    <form id="form1" runat="server">    <div>        <table style="width:759px;height:758px" cellpadding="0" cellspacing="0">            <tr>                <td style="background-image:url(images/壁纸1.jpg);width:759px;height:153px">                </td>            </tr>            <tr>                <td style="width:759px;height:498px" align="center" valign="middle">                    <asp:ContentPlaceHolder id="MainContent" runat="server">                           </asp:ContentPlaceHolder>                </td>            </tr>            <tr>                <td style="background-image:url(壁纸1.jpg);width:759px;height:107px">                </td>            </tr>        </table>           </div>    </form></body></html> SubMaster.master:<%@ Master Language="C#" CodeFile="SubMaster.master.cs" Inherits="SubMaster" MasterPageFile="~/MainMaster.master" %><asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">    <table style="background-image:url(images/壁纸2.jpg);width:759px;height:498px">        <tr>            <td align="center" valign="middle">                <asp:ContentPlaceHolder id="SubContent" runat="server">                       </asp:ContentPlaceHolder>            </td>        </tr>    </table></asp:Content> Default.aspx:<%@ Page Language="C#" MasterPageFile="~/SubMaster.master" CodeFile="Default.aspx.cs" Inherits="_Default" Title="Unitiled Page" %><asp:Content ID="Content1" ContentPlaceHolderID="SubContent" runat="server">    <table style="width:451px;height:391px">        <tr>            <td>                <h1>内容页</h1>            </td>        </tr>    </table></asp:Content>