EditorPartChrome クラスとは? わかりやすく解説

EditorPartChrome クラス

メモ : このクラスは、.NET Framework version 2.0新しく追加されたものです。

開発者が、EditorZoneBase ゾーン内の EditorPart コントロール選択したセクション表示だけをオーバーライドできるようにします。

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

Public Class EditorPartChrome
Dim instance As EditorPartChrome
public class EditorPartChrome
public ref class EditorPartChrome
public class EditorPartChrome
public class EditorPartChrome
解説解説

クロムとは、各 Web パーツ コントロールまたはゾーン内に含まれるサーバー コントロール周囲表示する周辺ユーザー インターフェイス (UI: User Interface) 要素のことです。コントロールクロムには、境界線タイトル バーアイコンタイトル テキストがあり、さらにはタイトル バー表示される動詞メニュー含まれます。クロム外観は、ゾーン レベルに対して設定されゾーン内のすべてのコントロール適用されます。

Web パーツ コントロール セットは、EditorPartChrome クラス使用して EditorPart コントロールクロム表示しますまた、このクラス使用すると、開発者EditorZoneBase ゾーン内の任意の EditorPart コントロール表示カスタマイズできます。たとえば、CreateEditorPartChromeStyle メソッドオーバーライドして、EditorZoneBase ゾーン定義されている特定のスタイル属性一部カスタマイズできます

EditorPartChrome クラスには、EditorPart コントロール表示オーバーライドする場合に役立つ複数重要なメソッド含まれています。1 つは、EditorPartChrome コンストラクタです。このコンストラクタは、カスタム EditorZoneBase クラスの CreateEditorPartChrome メソッドオーバーライドして、カスタム EditorPartChrome オブジェクトインスタンス作成する場合使用します。また RenderPartContents メソッド役立ちます。このメソッドは、 ヘッダーフッタータイトル バーなどのクロム要素とは異なるように、ゾーン内の コントロールコンテンツ領域表示制御する場合使用できます最後にEditorPart コントロール表示あらゆる要素プログラムで完全に制御する場合には、RenderEditorPart メソッドオーバーライドできます

実装時の注意 EditorPartChrome クラスから継承する場合カスタマイズした EditorPartChrome クラス返すためにカスタマイズした EditorZone ゾーン作成する必要があります。このクラス概要の「使用例」は、カスタマイズした EditorZone ゾーン作成しカスタマイズした EditorPartChrome クラス返す方法示してます。

使用例使用例

EditorPartChrome クラス使用して EditorZoneBase ゾーンEditorPart コントロール既定表示オーバーライドする方法次のコード例示します

コード例は、次の 3 つの部分構成されます。

コード例最初部分は、ユーザー コントロールです。ユーザー コントロールソース コードは、別のトピックのものを使用してます。このコード例実行するには、チュートリアル : Web パーツ ページでの表示モード変更トピック記載されているユーザー コントロール.ascx ファイルを、このコード例示されている .ascx ページと同じフォルダ配置する必要があります

コード例2 番目の部分Web ページです。コンパイルしたコンポーネントタグ プリフィックス登録するため、ファイル先頭近くには、Register ディレクティブ存在しますまた、このページは、<aspSample:MyEditorZone> 要素使用してカスタム エディタ ゾーン参照してます。

<%@ Page Language="VB" %>
<%@ register tagprefix="aspSample" 
  Namespace="Samples.AspNet.VB.Controls"
 %>
<%@ Register TagPrefix="uc1" TagName="DisplayModeMenuVB"
 Src="~/DisplayModeMenuVB.ascx" %>
<html>
<head id="Head1" runat="server">
  <title>Web Parts Page</title>
</head>
<body>
  <h1>Web Parts Demonstration Page</h1>
  <form runat="server" id="form1">
<asp:webpartmanager id="WebPartManager1" runat="server"
 />
<uc1:DisplayModeMenuVB runat=server ID="DisplayModeMenu"
 />
  <br />
  <table cellspacing="0" cellpadding="0"
 border="0">
    <tr>
      <td valign="top">
    <asp:webpartzone id="SideBarZone" runat="server"
 
        headertext="Sidebar">
        <zonetemplate>
        </zonetemplate>
      </asp:webpartzone>
      <aspSample:MyEditorZone ID="EditorZone1"
 runat="server">
      <ZoneTemplate>
        <asp:AppearanceEditorPart ID="AppearanceEditorPart1"
 
          runat="server" />
        <asp:LayoutEditorPart ID="LayoutEditorPart1"
 
          runat="server" />
      </ZoneTemplate>
    </aspSample:MyEditorZone>
      </td>
      <td valign="top">
    <asp:webpartzone id="MainZone" runat="server"
 headertext="Main">
         <zonetemplate>
        <asp:label id="contentPart" runat="server"
 title="Content">
              <h2>Welcome to My Home Page</h2>
              <p>Use links to visit my favorite sites!</p>
            </asp:label>
         </zonetemplate>
       </asp:webpartzone>
      </td>
      <td valign="top">
      </td>
    </tr>
  </table>
  </form>
</body>
</html>
<%@ Page Language="C#" %>
<%@ register tagprefix="aspSample" 
  Namespace="Samples.AspNet.CS.Controls" %>
<%@ Register TagPrefix="uc1" TagName="DisplayModeMenuCS" Src="~/DisplayModeMenuCS.ascx"
 %>
<html>
<head id="Head1" runat="server">
  <title>Web Parts Page</title>
</head>
<body>
  <h1>Web Parts Demonstration Page</h1>
  <form runat="server" id="form1">
<asp:webpartmanager id="WebPartManager1" runat="server" />
<uc1:DisplayModeMenuCS runat=server ID="DisplayModeMenu" />
  <br />
  <table cellspacing="0" cellpadding="0" border="0">
    <tr>
      <td valign="top">
    <asp:webpartzone id="SideBarZone" runat="server" 
        headertext="Sidebar">
        <zonetemplate>
        </zonetemplate>
      </asp:webpartzone>
      <aspSample:MyEditorZone ID="EditorZone1" runat="server">
      <ZoneTemplate>
        <asp:AppearanceEditorPart ID="AppearanceEditorPart1" 
          runat="server" />
        <asp:LayoutEditorPart ID="LayoutEditorPart1" 
          runat="server" />
      </ZoneTemplate>
    </aspSample:MyEditorZone>
      </td>
      <td valign="top">
    <asp:webpartzone id="MainZone" runat="server" headertext="Main">
         <zonetemplate>
        <asp:label id="contentPart" runat="server" title="Content">
              <h2>Welcome to My Home Page</h2>
              <p>Use links to visit my favorite sites!</p>
            </asp:label>
         </zonetemplate>
       </asp:webpartzone>
      </td>
      <td valign="top">
      </td>
    </tr>
  </table>
  </form>
</body>
</html>

コード例3 番目の部分は、カスタムエディタ パーツ クロムエディタ パーツ ゾーン実装含んでます。MyEditorZoneEditorZone拡張しCreateEditorPartChromeオーバーライドして、カスタムエディタ パーツ クロム返しますMyEditorPartChrome は、CreateEditorPartChromeStyle メソッドエディタ パーツ コントロール背景色変更しますゾーン背景色は PerformPreRender メソッド変更されRenderPartContents メソッドエディタ パーツテキスト追加されます。

Namespace Samples.AspNet.VB.Controls


    <AspNetHostingPermission(SecurityAction.Demand, _
      Level:=AspNetHostingPermissionLevel.Minimal)> _
    <AspNetHostingPermission(SecurityAction.InheritanceDemand, _
      Level:=AspNetHostingPermissionLevel.Minimal)> _
    Public Class MyEditorPartChrome
        Inherits EditorPartChrome

        Public Sub New(ByVal
 zone As EditorZoneBase)
            MyBase.New(zone)
        End Sub

        Protected Overrides Function
 CreateEditorPartChromeStyle(ByVal editorPart As
 System.Web.UI.WebControls.WebParts.EditorPart, ByVal chromeType As System.Web.UI.WebControls.WebParts.PartChromeType) As
 System.Web.UI.WebControls.Style
            Dim editorStyle As Style
            editorStyle = MyBase.CreateEditorPartChromeStyle(editorPart,
 chromeType)
            editorStyle.BackColor = Drawing.Color.Bisque
            Return editorStyle
        End Function

        Public Overrides Sub
 PerformPreRender()
            Dim zoneStyle As Style = New
 Style
            zoneStyle.BackColor = Drawing.Color.Cornsilk

            Zone.Page.Header.StyleSheet.RegisterStyle(zoneStyle, Nothing)
            Zone.MergeStyle(zoneStyle)
        End Sub

        Protected Overrides Sub
 RenderPartContents(ByVal writer As System.Web.UI.HtmlTextWriter,
 ByVal editorPart As System.Web.UI.WebControls.WebParts.EditorPart)
            writer.AddStyleAttribute("color", "red")
            writer.RenderBeginTag("p")
            writer.Write("Apply all changes")
            writer.RenderEndTag()
            editorPart.RenderControl(writer)
        End Sub

        Public Overrides Sub
 RenderEditorPart(ByVal writer As System.Web.UI.HtmlTextWriter,
 ByVal editorPart As System.Web.UI.WebControls.WebParts.EditorPart)
            MyBase.RenderEditorPart(writer, editorPart)
        End Sub
    End Class


    <AspNetHostingPermission(SecurityAction.Demand, _
      Level:=AspNetHostingPermissionLevel.Minimal)> _
    <AspNetHostingPermission(SecurityAction.InheritanceDemand, _
      Level:=AspNetHostingPermissionLevel.Minimal)> _
    Public Class MyEditorZone
        Inherits EditorZone

        Protected Overrides Function
 CreateEditorPartChrome() As System.Web.UI.WebControls.WebParts.EditorPartChrome
            Return New MyEditorPartChrome(Me)
        End Function
    End Class
End Namespace
namespace Samples.AspNet.CS.Controls
{

    [AspNetHostingPermission(SecurityAction.Demand,
      Level = AspNetHostingPermissionLevel.Minimal)]
    [AspNetHostingPermission(SecurityAction.InheritanceDemand,
      Level = AspNetHostingPermissionLevel.Minimal)]
    public class MyEditorPartChrome : EditorPartChrome
    {
        public MyEditorPartChrome(EditorZoneBase zone)
            : base(zone)
        {

        }
        
        protected override Style CreateEditorPartChromeStyle(EditorPart
 editorPart, PartChromeType chromeType)
        {
            Style editorStyle = base.CreateEditorPartChromeStyle(editorPart,
 chromeType);
            editorStyle.BackColor = Color.Bisque;
            return editorStyle;
        }

        public override void PerformPreRender()
        {
            Style zoneStyle = new Style();
            zoneStyle.BackColor = Color.Cornsilk;

            Zone.Page.Header.StyleSheet.RegisterStyle(zoneStyle, null);
            Zone.MergeStyle(zoneStyle);
        }

        protected override void RenderPartContents(HtmlTextWriter
 writer, EditorPart editorPart)
        {
            writer.AddStyleAttribute("color", "red");
            writer.RenderBeginTag("p");
            writer.Write("Apply all changes");
            writer.RenderEndTag();
            editorPart.RenderControl(writer);
        }

        public override void RenderEditorPart(HtmlTextWriter
 writer, EditorPart editorPart)
        {
            base.RenderEditorPart(writer, editorPart);
        }
    }

    [AspNetHostingPermission(SecurityAction.Demand,
      Level = AspNetHostingPermissionLevel.Minimal)]
    [AspNetHostingPermission(SecurityAction.InheritanceDemand,
      Level = AspNetHostingPermissionLevel.Minimal)]
    public class MyEditorZone : EditorZone
    {
        protected override EditorPartChrome CreateEditorPartChrome()
        {
            return new MyEditorPartChrome(this);
        }
    }
}
.NET Framework のセキュリティ.NET Frameworkセキュリティ
継承階層継承階層
System.Object
  System.Web.UI.WebControls.WebParts.EditorPartChrome
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
EditorPartChrome メンバ
System.Web.UI.WebControls.WebParts 名前空間



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

辞書ショートカット

すべての辞書の索引

「EditorPartChrome クラス」の関連用語

EditorPartChrome クラスのお隣キーワード
検索ランキング

   

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



EditorPartChrome クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS