Using nested Master Pages

Posted by abatishchev on Stack Overflow See other posts from Stack Overflow or by abatishchev
Published on 2009-01-24T13:56:41Z Indexed on 2010/05/22 13:10 UTC
Read the original article Hit count: 580

Filed under:
|
|
|
|

Hi. I'm very new to ASP.NET, help me please understand MasterPages conception more.

I have Site.master with common header data (css, meta, etc), center form (blank) and footer (copyright info, contact us link, etc).

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="_SiteMaster" %>
<!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 id="tagHead" runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" href="styles.css" type="text/css" />
</head>
<body>
    <form id="frmMaster" runat="server">
    <div>
        <asp:ContentPlaceHolder ID="holderForm" runat="server"></asp:ContentPlaceHolder>
        <asp:ContentPlaceHolder ID="holderFooter" runat="server">Some footer here</asp:ContentPlaceHolder>
    </div>
    </form>
</body>
</html>

and I want to use second master page for a project into sub directory, which would contains SQL query on Page_Load for logging (it isn't necessary for whole site).

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Project.master.cs" Inherits="_ProjectMaster" MasterPageFile="~/Site.master" %>
<asp:Content ContentPlaceHolderID="holderForm" runat="server">
    <asp:ContentPlaceHolder ID="holderForm" runat="server" EnableViewState="true"></asp:ContentPlaceHolder>
</asp:Content>
<asp:Content ContentPlaceHolderID="holderFooter" runat="server">
    <asp:ContentPlaceHolder ID="holderFooter" runat="server" EnableViewState="true"></asp:ContentPlaceHolder>
</asp:Content>

But I have a problem: footer isn't displayed.

Where is my mistake? Am I right to use second master page as super class for logging?

Project page looks like this:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" MasterPageFile="~/Project.master" %>
<asp:Content ContentPlaceHolderID="holderForm" runat="server">
    <p>Hello World!</p>
</asp:Content>
<asp:Content ContentPlaceHolderID="holderFooter" runat="Server">
    Some footer content
</asp:Content>

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET