ASP.NET Podcast Show #99 - Nested Master Pages in Visual Studio 2008 (video and audio)

Subscribe <-- What everyone wants.

Original url: http://aspnetpodcast.com/CS11/blogs/asp.net_podcast/archive/2007/08/22/asp-net-podcast-show-99-nested-master-pages-in-visual-studio-2008.aspx

Download as WMV

Download as M4V for iPod and Zune

Download as MP3 audio only

Show Notes:

This show is a video demo of creating a nested master page in Visual Studio 2008.

The source code for the parent master page is:

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPageParentSimple.master.cs" Inherits="MasterPageParentSimple" %>

<!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>Untitled Page</title>
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        Simple Parent Master Page.<br />
        <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
       
        </asp:ContentPlaceHolder>
    </div>
    </form>
</body>
</html>

The source code for the example child master page is:

<%@ Master Language="C#" MasterPageFile="~/MasterPageParentSimple.master" AutoEventWireup="false" CodeFile="MasterPageChildSimple.master.cs" Inherits="MasterPageChildSimple" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    Simple Child Master Page<br />
    The location of the ContentPlaceHolder was the one hangup I had.<br />
    <asp:ContentPlaceHolder ID="Content3" runat="server">
    </asp:ContentPlaceHolder>
</asp:Content>

The source code for the example simple out page is:

<%@ Page Language="C#" MasterPageFile="~/MasterPageChildSimple.master" AutoEventWireup="true" CodeFile="DefaultSimpleMasterPageExample.aspx.cs" Inherits="DefaultSimpleMasterPageExample" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Content3" Runat="Server">
    this is some basic content. this is more content.
</asp:Content>

Here is some exact output (not a perfect match, but close).

Nested Master page output

If you want to see some more on nested master pages, check this post out:

http://morewally.com/cs/blogs/wallym/archive/2007/08/09/visual-studio-2008-thursday-august-9-2008.aspx

No Comments