MasterPage.MasterPageFile プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > MasterPage.MasterPageFile プロパティの意味・解説 

MasterPage.MasterPageFile プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

現在のコンテンツ格納されているマスタ ページの名前を取得または設定します

名前空間: System.Web.UI
アセンブリ: System.Web (system.web.dll 内)
構文構文

Dim instance As MasterPage
Dim value As String

value = instance.MasterPageFile

instance.MasterPageFile = value
public string MasterPageFile { get;
 set; }
public:
property String^ MasterPageFile {
    String^ get ();
    void set (String^ value);
}
/** @property */
public String get_MasterPageFile ()

/** @property */
public void set_MasterPageFile (String value)
public function get MasterPageFile
 () : String

public function set MasterPageFile
 (value : String)

プロパティ
現在のマスタ ページの親であるマスタ ページの名前。現在のマスタ ページに親が存在しない場合null 参照 (Visual Basic では Nothing)。

例外例外
例外種類条件

InvalidOperationException

MasterPageFile プロパティ設定できるのは、PreInit イベントの中か前だけです。

使用例使用例

このセクションには、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 という名前のコンテンツ ページ使用する方法次のコード例示します

<%@ Page Language="C#" MasterPageFile="~/ChildMasterPage_1cs.master"
 Title="Untitled Page"%>

<asp:content runat="server" contentplaceholderid="ContentPlaceHolder2">
This is the content of a Content control.
</asp:content>
<%@ Page Language="VB" MasterPageFile="~/ChildMasterPage_1vb.master"
 Title="Untitled Page"%>

<asp:content runat="server" contentplaceholderid="ContentPlaceHolder2">
This is the content of a Content control.
</asp:content>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からMasterPage.MasterPageFile プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からMasterPage.MasterPageFile プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からMasterPage.MasterPageFile プロパティ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

MasterPage.MasterPageFile プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



MasterPage.MasterPageFile プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS