MasterPage.Master プロパティ
アセンブリ: System.Web (system.web.dll 内)

Dim instance As MasterPage Dim value As MasterPage value = instance.Master
public MasterPage Master { get; }
public: property MasterPage^ Master { MasterPage^ get (); }
/** @property */ public MasterPage get_Master ()
現在のマスタ ページの親であるマスタ ページ。現在のマスタ ページに親が存在しない場合は null 参照 (Visual Basic では Nothing)。


このセクションには、3 つのコード例が含まれています。最初のコード例では、入れ子になったマスタ ページを作成します。2 番目のコード例では、最初のコード例で作成したマスタ ページを参照する方法を示します。3 番目のコード例では、コンテンツ ページを使用して、2 番目のコード例で作成したマスタ ページを参照する方法を示します。
入れ子になったマスタ ページを作成する方法を次のコード例に示します。この例は、ParentMasterPage_1 という名前の親マスタ ページを表しています。
<%@ Master Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html > <head runat="server"> <title>Nested Master Page Example</title> </head> <body> <form id="form1" runat="server"> <h1>This is content in the parent master page.</h1> <div> <asp:contentplaceholder id="ContentPlaceHolder1" runat="server"> </asp:contentplaceholder> </div> </form> </body> </html>
<%@ Master Language="VB" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html > <head runat="server"> <title>Nested Master Page Example</title> </head> <body> <form id="form1" runat="server"> <h1>This is content in the parent master page.</h1> <div> <asp:contentplaceholder id="ContentPlaceHolder1" runat="server"> </asp:contentplaceholder> </div> </form> </body> </html>
前述のコード例で作成したマスタ ページを参照する、ChildMasterPage_1 という名前の入れ子になったマスタ ページを使用する方法を次のコード例に示します。
<%@ Master Language="C#" MasterPageFile="~/ParentMasterPage_1cs.master" %> <asp:Content Runat="Server" ContentPlaceHolderID="ContentPlaceHolder1"> <h2>This is the content of a nested Master Page.</h2> <div> <asp:contentplaceholder id="ContentPlaceHolder2" runat="server"> </asp:contentplaceholder> </div> </asp:Content>
<%@ Master Language="VB" MasterPageFile="~/ParentMasterPage_1vb.master" %> <asp:Content Runat="Server" ContentPlaceHolderID="ContentPlaceHolder1"> <h2>This is the content of a nested Master Page.</h2> <div> <asp:contentplaceholder id="ContentPlaceHolder2" runat="server"> </asp:contentplaceholder> </div> </asp:Content>
前述のコード例で作成した ChildMasterPage_1 を参照する、ContentPage という名前のコンテンツ ページを使用する方法を次のコード例に示します。

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- MasterPage.Master プロパティのページへのリンク