CatalogPartChrome クラス
アセンブリ: System.Web (system.web.dll 内)
構文
解説
クロムとは、ゾーン内に含まれる各 Web パーツ コントロールまたはサーバー コントロールの周囲に表示する周辺ユーザー インターフェイス (UI: User Interface) 要素のことです。コントロールのクロムには、境界線、タイトル バー、アイコン、タイトル テキストがあり、さらにはタイトル バーに表示される動詞メニューも含まれます。クロムの外観は、ゾーン レベルに対して設定され、ゾーン内のすべてのコントロールに適用されます。
Web パーツ コントロール セットは、CatalogPartChrome クラスを使用して CatalogPart コントロールのクロムを表示します。さらに、このクラスを使用すると、開発者は CatalogZoneBase ゾーン内の任意の CatalogPart コントロールの表示をカスタマイズできます。たとえば、CreateCatalogPartChromeStyle メソッドをオーバーライドして、CatalogZoneBase ゾーンに適用されている特定のスタイル属性の一部をカスタマイズできます。
CatalogPartChrome クラスには、CatalogPart コントロールの表示をオーバーライドする場合に役立つ複数の重要なメソッドが含まれています。その 1 つは、CatalogPartChrome コンストラクタです。このコンストラクタは、カスタム CatalogZoneBase ゾーンの CreateCatalogPartChrome メソッドをオーバーライドして、カスタム CatalogPartChrome オブジェクトのインスタンスを作成する場合に使用します。また RenderPartContents メソッドも役立ちます。このメソッドは、 ヘッダー、フッター、タイトル バーなどのクロム要素とは異なるように、ゾーン内の コントロールのコンテンツ領域の表示を制御する場合に使用できます。最後に、CatalogPart コントロールの表示のあらゆる要素をプログラムで完全に制御する場合には、RenderCatalogPart メソッドをオーバーライドできます。
実装時の注意 CatalogPartChrome クラスから継承する場合は、カスタマイズしたCatalogZone ゾーンを作成し、カスタマイズした CatalogPartChrome クラスを返す必要があります。このクラス概要の「例」は、カスタマイズした CatalogZone ゾーンを作成し、カスタマイズした CatalogPartChrome クラスを返す方法を示しています。CatalogPartChrome クラスを使用して CatalogZoneBase ゾーンの CatalogPart コントロールの既定の表示をオーバーライドする方法を次のコード例に示します。
コード例の最初の部分は、ユーザー コントロールです。ユーザー コントロールのソース コードは、別のトピックのものを使用しています。このコード例を実行するには、チュートリアル : Web パーツ ページでの表示モードの変更 のトピックに記載されているユーザー コントロールの .ascx ファイルを、このコード例に示されている .ascx ページと同じフォルダに配置する必要があります。
コード例の 2 番目の部分は Web ページです。コンパイルしたコンポーネントとタグ プリフィックスを登録するため、ファイルの先頭近くには、Register ディレクティブが存在します。また、このページは、<aspSample:MyCatalogZone> 要素を使用してカスタム カタログ ゾーンを参照します。
<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:MyCatalogZone ID="CatalogZone1" runat="server"> <ZoneTemplate> <asp:ImportCatalogPart ID="ImportCatalog" runat="server" /> </ZoneTemplate> </aspSample:MyCatalogZone> </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="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:MyCatalogZone ID="CatalogZone1" runat="server"> <ZoneTemplate> <asp:ImportCatalogPart ID="ImportCatalog" runat="server" /> </ZoneTemplate> </aspSample:MyCatalogZone> </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:MyCatalogZone ID="CatalogZone1" runat="server"> <ZoneTemplate> <asp:ImportCatalogPart ID="ImportCatalog" runat="server" /> </ZoneTemplate> </aspSample:MyCatalogZone> </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 番目の部分には、カスタムのカタログ パーツ クロムおよびカタログ パーツ ゾーンの実装が含まれています。MyCatalogZone は CatalogZone を拡張して CreateCatalogPartChrome をオーバーライドし、カスタムのカタログ パーツ クロムを返します。MyCatalogPartChrome は、CreateCatalogPartChromeStyle メソッドのカタログ コントロールの背景色を変更します。ゾーンの背景色は PerformPreRender メソッドで変更し、テキストは RenderPartContents メソッドでカタログ パーツに追加されます。
Namespace Samples.AspNet.VB.Controls Public Class MyCatalogPartChrome Inherits CatalogPartChrome Public Sub New(ByVal zone As CatalogZoneBase) MyBase.New(zone) End Sub Protected Overrides Function CreateCatalogPartChromeStyle(ByVal catalogPart As System.Web.UI.WebControls.WebParts.CatalogPart, ByVal chromeType As System.Web.UI.WebControls.WebParts.PartChromeType) As System.Web.UI.WebControls.Style Dim editorStyle As Style editorStyle = MyBase.CreateCatalogPartChromeStyle(catalogPart, 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 catalogPart As System.Web.UI.WebControls.WebParts.CatalogPart) writer.AddStyleAttribute("color", "red") writer.RenderBeginTag("p") writer.Write("Apply all changes") writer.RenderEndTag() catalogPart.RenderControl(writer) End Sub Public Overrides Sub RenderCatalogPart(ByVal writer As System.Web.UI.HtmlTextWriter, ByVal catalogPart As System.Web.UI.WebControls.WebParts.CatalogPart) MyBase.RenderCatalogPart(writer, catalogPart) End Sub End Class Public Class MyCatalogZone Inherits CatalogZone Protected Overrides Function CreateCatalogPartChrome() As System.Web.UI.WebControls.WebParts.CatalogPartChrome Return New MyCatalogPartChrome(Me) End Function End Class End Namespace
namespace Samples.AspNet.CS.Controls { /// <summary> /// Summary description for source /// </summary> public class MyCatalogPartChrome : CatalogPartChrome { public MyCatalogPartChrome(CatalogZoneBase zone) : base(zone) { } protected override Style CreateCatalogPartChromeStyle(CatalogPart catalogPart, PartChromeType chromeType) { Style catalogStyle = base.CreateCatalogPartChromeStyle(catalogPart, chromeType); catalogStyle.BackColor = Color.Bisque; return catalogStyle; } 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, CatalogPart catalogPart) { writer.AddStyleAttribute("color", "red"); writer.RenderBeginTag("p"); writer.Write("Apply all changes"); writer.RenderEndTag(); catalogPart.RenderControl(writer); } public override void RenderCatalogPart(HtmlTextWriter writer, CatalogPart catalogPart) { base.RenderCatalogPart(writer, catalogPart); } } public class MyCatalogZone : CatalogZone { protected override CatalogPartChrome CreateCatalogPartChrome() { return new MyCatalogPartChrome(this); } } }
System.Web.UI.WebControls.WebParts.CatalogPartChrome
プラットフォーム
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
CatalogPartChrome コンストラクタ
アセンブリ: System.Web (system.web.dll 内)
構文
例外
解説
CatalogPartChrome コンストラクタは、CatalogPartChrome クラスの新しいインスタンスを初期化します。これは、主に CatalogZoneBase ゾーンによってその CreateCatalogPartChrome メソッド内で使用され、クロムのレンダリングおよびそのゾーン内の CatalogPart コントロールの任意のカスタム レンダリングを処理する CatalogPartChrome オブジェクトのインスタンスを作成します。
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
CatalogPartChrome プロパティ
プロテクト プロパティ
参照
関連項目
CatalogPartChrome クラスSystem.Web.UI.WebControls.WebParts 名前空間
CreateCatalogPartChrome
CatalogPart クラス
WebPartChrome
EditorPartChrome
その他の技術情報
ASP.NET Web パーツ ページCatalogPartChrome メソッド
パブリック メソッド
名前 | 説明 | |
---|---|---|
Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) | |
GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) | |
GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) | |
PerformPreRender | CatalogPart コントロールを表示する前に行う必要があるタスクを実行します。 | |
ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) | |
RenderCatalogPart | 完全な CatalogPart コントロールとそのすべてのセクションを表示します。 | |
ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |
名前 | 説明 | |
---|---|---|
CreateCatalogPartChromeStyle | CatalogPartChrome オブジェクトによって表示される各 CatalogPart コントロールのスタイル属性を提供するスタイル オブジェクトを作成します。 | |
Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) | |
MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) | |
RenderPartContents | ヘッダーおよびフッターを除いた CatalogPart コントロールのメインの内容表示領域を表示します。 |
関連項目
CatalogPartChrome クラスSystem.Web.UI.WebControls.WebParts 名前空間
CreateCatalogPartChrome
CatalogPart クラス
WebPartChrome
EditorPartChrome
その他の技術情報
ASP.NET Web パーツ ページCatalogPartChrome メンバ
開発者が、CatalogZoneBase ゾーン内の CatalogPart コントロールの選択したセクションの表示だけをオーバーライドできるようにします。
CatalogPartChrome データ型で公開されるメンバを以下の表に示します。
パブリック コンストラクタ
プロテクト プロパティ
パブリック メソッド
名前 | 説明 | |
---|---|---|
Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) | |
GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) | |
GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) | |
PerformPreRender | CatalogPart コントロールを表示する前に行う必要があるタスクを実行します。 | |
ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) | |
RenderCatalogPart | 完全な CatalogPart コントロールとそのすべてのセクションを表示します。 | |
ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |
名前 | 説明 | |
---|---|---|
CreateCatalogPartChromeStyle | CatalogPartChrome オブジェクトによって表示される各 CatalogPart コントロールのスタイル属性を提供するスタイル オブジェクトを作成します。 | |
Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) | |
MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) | |
RenderPartContents | ヘッダーおよびフッターを除いた CatalogPart コントロールのメインの内容表示領域を表示します。 |
関連項目
CatalogPartChrome クラスSystem.Web.UI.WebControls.WebParts 名前空間
CreateCatalogPartChrome
CatalogPart クラス
WebPartChrome
EditorPartChrome
その他の技術情報
ASP.NET Web パーツ ページ- CatalogPartChromeのページへのリンク