System.Web.UI.WebControls 名 ...


.NET Framework クラス ライブラリ
ContentPlaceHolder クラス

更新 : 2007 年 11 月

ASP.NET マスタ ページにコンテンツの領域を定義します。

名前空間 :  System.Web.UI.WebControls
アセンブリ :  System.Web (System.Web.dll 内)

構文

Visual Basic (宣言)
<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
<AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
Public Class ContentPlaceHolder _
    Inherits Control _
    Implements INamingContainer
Visual Basic (使用法)
Dim instance As ContentPlaceHolder
C#
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class ContentPlaceHolder : Control, 
    INamingContainer
Visual C++
[AspNetHostingPermissionAttribute(SecurityAction::LinkDemand, Level = AspNetHostingPermissionLevel::Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction::InheritanceDemand, Level = AspNetHostingPermissionLevel::Minimal)]
public ref class ContentPlaceHolder : public Control, 
    INamingContainer
J#
/** @attribute AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal) */
/** @attribute AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal) */
public class ContentPlaceHolder extends Control implements INamingContainer
JScript
public class ContentPlaceHolder extends Control implements INamingContainer
ASP.NET
<asp:ContentPlaceHolder />
解説

ContentPlaceHolder コントロールはマスタ ページにコンテンツの相対領域を定義し、コンテンツ ページ内にある関連付けられた Content コントロールからすべてのテキスト、マークアップ、およびサーバー コントロールを表示します。

Content コントロールはその ContentPlaceHolderID プロパティを使用して、ContentPlaceHolder に関連付けられます。ContentPlaceHolderID プロパティを、マスタ ページの関連付けられた ContentPlaceHolder コントロールの ID プロパティの値に設定します。マスタ ページには、1 つ以上の ContentPlaceHolder を宣言できます。

コンテンツ ページでは、マスタ ページの ContentPlaceHolder のコンテンツを提供できるのは 1 つの Content コントロールだけです。ただし、マスタ ページを使用するコンテンツ ページごとに、別々の Content コントロールを ContentPlaceHolder に関連付けることができます。たとえば、マスタ ページのページ タイトルに ContentPlaceHolder を定義できます。マスタ ページを使用するコンテンツ ページごとに、ページ タイトルのテキストおよびマークアップを提供する Content コントロールを追加できます。

メモ :

XHtml に準拠するため、タイトルが定義されていない場合や見つからない場合は空のタイトル要素が作成されます。

ContentPlaceHolder コントロールのタグ内に置かれる既定のコンテンツを指定できますが、このコンテンツはコンテンツ ページに関連付けられた任意のコンテンツで置き換えられます。

マスタ ページおよびコンテンツ ページの詳細については、「ASP.NET マスター ページ」を参照してください。

TopicLocation
チュートリアル : Visual Web Developer での ASP.NET マスタ ページの作成と使用Visual Studio での ASP .NET Web アプリケーションの作成
チュートリアル : Visual Web Developer での ASP.NET マスタ ページの作成と使用Visual Web Developer でのアプリケーションの作成
チュートリアル : Web サイトへのサイト ナビゲーションの追加Visual Studio での ASP .NET Web アプリケーションの作成
チュートリアル : Web サイトへのサイト ナビゲーションの追加Visual Web Developer でのアプリケーションの作成
チュートリアル: Web サイトへの追加のサイト ナビゲーションdv_vwdcon
チュートリアル: 作成と Visual Web Developer で ASP.NET マスター ページを使用します。dv_vwdcon
方法 : ASP.NET マスタ ページ用のコンテンツ ページを作成するVisual Studio ASP .NET での Web アプリケーションの作成
方法 : ASP.NET マスタ ページ用のコンテンツ ページを作成する (Visual Studio)Visual Studio での ASP .NET Web アプリケーションの作成
方法 : ASP.NET マスター ページのコンテンツ ページを作成します。dv_vwdcon
方法 : ASP.NET マスター ページのコンテンツを参照するASP .NET Web アプリケーションの作成
方法 : ASP.NET マスター ページのコンテンツを参照するVisual Studio ASP .NET での Web アプリケーションの作成
方法 : 参照 ASP.NET マスター ページの内容dv_vwdcon

ContentPlaceHolder コントロールを使用して、マスタ ページのコンテンツ領域を定義する方法のコード例を次に示します。最初の Web ページはマスタ ページで、ContentPlaceHolder コントロールを使用してコンテンツ領域を定義します。

Visual Basic
<%@ 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>MasterPage Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:contentplaceholder id="ContentPlaceHolder1" runat="server" />
    </div>
    </form>
</body>
</html>
C#
<%@ 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>MasterPage Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:contentplaceholder id="ContentPlaceHolder1" runat="server" />
    </div>
    </form>
</body>
</html>

前述のマスタ ページのコンテンツ ページのコード例を次に示します。Content コントロール テンプレート内に定義されているテキスト、マークアップ、およびサーバー コントロールが、マスタ ページの ContentPlaceHolder に表示されます。

Visual Basic
Class SampleMasterClass
         Inherits System.Web.UI.MasterPage
     Dim asitename As String
     Public Property SiteName() As String
       Get
         Return asitename
       End Get
       Set(ByVal Value as String)
         asitename = Value
       End Set
     End Property
End Class
C#
public class SampleMasterClass : System.Web.UI.MasterPage {
     private string sitename;     
     public string SiteName
     {
        get {return(sitename);}
        set {sitename = value;}
     }
}
アクセス許可

継承階層

System..::.Object
  System.Web.UI..::.Control
    System.Web.UI.WebControls..::.ContentPlaceHolder
スレッド セーフ

この型のすべてのパブリック static (Visual Basic では Shared) メンバは、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォーム

Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

.NET Framework および .NET Compact Framework では、各プラットフォームのすべてのバージョンはサポートしていません。サポートされているバージョンについては、「.NET Framework システム要件」を参照してください。

バージョン情報

.NET Framework

サポート対象 : 3.5、3.0、2.0
参照

参照

その他の技術情報

タグ :


Page view tracker