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

Dim instance As Part Dim value As PartChromeType value = instance.ChromeType instance.ChromeType = value
public: virtual property PartChromeType ChromeType { PartChromeType get (); void set (PartChromeType value); }
/** @property */ public PartChromeType get_ChromeType () /** @property */ public void set_ChromeType (PartChromeType value)
public function get ChromeType () : PartChromeType public function set ChromeType (value : PartChromeType)
PartChromeType 値の 1 つ。既定値は Default です。


パーツ コントロールの周囲に表示する境界線の種類は、コントロールの ChromeType プロパティによって決まります。使用できるオプションには、タイトルのみ表示、境界線のみ表示、タイトルと境界線を表示、何も表示しない、または既定のオプション (単に PartChromeType プロパティの値を使用) があります。
継承時の注意 WebPart などの派生クラスでは、ChromeType をオーバーライドして、コントロールを囲む境界線の種類をユーザーがパーソナル化できるようにできます。
パーツ コントロールで、ChromeType プロパティを宣言によって使用するコード例を次に示します。この例には、TextDisplayWebPart というカスタムの WebPart コントロールが必要です。これについては、Part クラスの概要にある「例」を参照してください。
Web ページの宣言コードで、TextDisplayWebPart コントロールの 2 番目のインスタンスでは、ChromeType プロパティがタイトルのみ表示するように設定されています。これに対して、最初のインスタンスでは、タイトルと境界線を表示するように設定されています。ブラウザでページを読み込むと、コントロールの 2 番目のインスタンスは、最小化された状態で表示されます。このコントロールを最大化すると、タイトルが表示され、境界線は表示されません。
<%@ page language="VB" %> <%@ register tagprefix="aspSample" Namespace="Samples.AspNet.VB.Controls" Assembly="TextDisplayWebPartVB" %> <html> <head id="Head1" runat="server"> </head> <body> <form id="Form1" runat="server"> <asp:webpartmanager id="WebPartManager1" runat="server" /> <asp:webpartzone id="WebPartZone1" runat="server" backcolor="#99cccc"> <parttitlestyle font-bold="true" forecolor="#ffffff" /> <partstyle borderwidth="1px" borderstyle="Solid" bordercolor="#81AAF2" /> <zonetemplate> <aspSample:TextDisplayWebPart runat="server" id="textwebpart" title = "Text Content WebPart" Description="A text content WebPart control." ChromeType="TitleAndBorder" width="350px" /> </zonetemplate> </asp:webpartzone> <asp:webpartzone id="WebPartZone2" runat="server" backcolor="#99cccc"> <parttitlestyle font-bold="true" forecolor="#ffffff" /> <partstyle borderwidth="1px" borderstyle="Solid" bordercolor="#81AAF2" /> <zonetemplate> <aspSample:TextDisplayWebPart runat="server" id="textwebpart2" title = "Text Content WebPart 2" Description="A text content WebPart control." ChromeType="TitleOnly" ChromeState="Minimized" width="350px" /> </zonetemplate> </asp:webpartzone> </form> </body> </html>
<%@ page language="C#" %> <%@ register tagprefix="aspSample" Namespace="Samples.AspNet.CS.Controls" Assembly="TextDisplayWebPartCS" %> <html> <head id="Head1" runat="server"> </head> <body> <form id="Form1" runat="server"> <asp:webpartmanager id="WebPartManager1" runat="server" /> <asp:webpartzone id="WebPartZone1" runat="server" backcolor="#99cccc"> <parttitlestyle font-bold="true" forecolor="#ffffff" /> <partstyle borderwidth="1px" borderstyle="Solid" bordercolor="#81AAF2" /> <zonetemplate> <aspSample:TextDisplayWebPart runat="server" id="textwebpart" title = "Text Content WebPart" Description="A text content WebPart control." ChromeType="TitleAndBorder" width="350px" /> </zonetemplate> </asp:webpartzone> <asp:webpartzone id="WebPartZone2" runat="server" backcolor="#99cccc"> <parttitlestyle font-bold="true" forecolor="#ffffff" /> <partstyle borderwidth="1px" borderstyle="Solid" bordercolor="#81AAF2" /> <zonetemplate> <aspSample:TextDisplayWebPart runat="server" id="textwebpart2" title = "Text Content WebPart 2" Description="A text content WebPart control." ChromeType="TitleOnly" ChromeState="Minimized" width="350px" /> </zonetemplate> </asp:webpartzone> </form> </body> </html>
<%@ page language="VJ#" %> <%@ register tagprefix="aspSample" Namespace="Samples.AspNet.JSL.Controls" Assembly="TextDisplayWebPartJSL" %> <html> <head id="Head1" runat="server"> </head> <body> <form id="Form1" runat="server"> <asp:webpartmanager id="WebPartManager1" runat="server" /> <asp:webpartzone id="WebPartZone1" runat="server" backcolor="#99cccc"> <parttitlestyle font-bold="true" forecolor="#ffffff" /> <partstyle borderwidth="1px" borderstyle="Solid" bordercolor="#81AAF2" /> <zonetemplate> <aspSample:TextDisplayWebPart runat="server" id="textwebpart" title = "Text Content WebPart" Description="A text content WebPart control." ChromeType="TitleAndBorder" width="350px" /> </zonetemplate> </asp:webpartzone> <asp:webpartzone id="WebPartZone2" runat="server" backcolor="#99cccc"> <parttitlestyle font-bold="true" forecolor="#ffffff" /> <partstyle borderwidth="1px" borderstyle="Solid" bordercolor="#81AAF2" /> <zonetemplate> <aspSample:TextDisplayWebPart runat="server" id="textwebpart2" title = "Text Content WebPart 2" Description="A text content WebPart control." ChromeType="TitleOnly" ChromeState="Minimized" width="350px" /> </zonetemplate> </asp:webpartzone> </form> </body> </html>

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


PartChromeType 列挙体
アセンブリ: System.Web (system.web.dll 内)

Public Enumeration PartChromeType

メンバ名 | 説明 | |
---|---|---|
BorderOnly | 境界線のみ、タイトル バーなし。 | |
Default | ゾーンを格納しているパーツ コントロールから継承された境界線の設定。 | |
None | 境界線なし、タイトル バーなし。 | |
TitleAndBorder | タイトル バーと境界線。 | |
TitleOnly | タイトル バーのみ、境界線なし。 |

パーツ コントロールの PartChromeType 列挙体は、Web パーツ コントロールを囲む境界線の種類を決定します。タイトル バーのみ表示する、境界線のみ表示する、タイトル バーと境界線を表示する、または何も表示しないためのオプションがあります。
パーツ コントロールの ChromeType プロパティで列挙値が Default に設定されている場合、コントロールはそのコントロールを格納しているゾーンの PartChromeType プロパティから設定を継承します。

ASP.NET Web ページで参照されるカスタム WebPart コントロールを使用して、PartChromeType 列挙体を宣言によって使用するコード例を次に示します。コード例を実行するためには、このソース コードをコンパイルする必要があります。それを明示的にコンパイルし、コンパイル済みのアセンブリを Web サイトの Bin フォルダまたはグローバル アセンブリ キャッシュに配置できます。サイトの App_Code フォルダにソース コードを配置し、実行時に動的にコンパイルすることもできます。両方のコンパイル方法を示すチュートリアルについては、「チュートリアル : カスタム サーバー コントロールの開発と使用」を参照してください。
この例の最初の部分には、TextDisplayWebPart という名前のカスタム コントロールのコードが含まれています。このコントロールは WebPart から派生するため、PartChromeType 列挙体を戻り型として使用する ChromeType プロパティなど、Part クラスが提供する共通プロパティも継承します。
Imports System Imports System.Security.Permissions Imports System.Web Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.Web.UI.WebControls.WebParts Namespace Samples.AspNet.VB.Controls <AspNetHostingPermission(SecurityAction.Demand, _ Level := AspNetHostingPermissionLevel.Minimal)> _ <AspNetHostingPermission(SecurityAction.InheritanceDemand, _ Level := AspNetHostingPermissionLevel.Minimal)> _ Public Class TextDisplayWebPart Inherits WebPart Private _contentText As String = Nothing Private input As TextBox Private DisplayContent As Label Public Sub New() Me.AllowClose = False End Sub <Personalizable(), WebBrowsable()> _ Public Property ContentText() As String Get Return _contentText End Get Set _contentText = value End Set End Property Protected Overrides Sub CreateChildControls() Controls.Clear() DisplayContent = New Label() DisplayContent.Text = Me.ContentText DisplayContent.BackColor = _ System.Drawing.Color.LightBlue Me.Controls.Add(DisplayContent) input = New TextBox() Me.Controls.Add(input) Dim update As New Button() update.Text = "Set Label Content" AddHandler update.Click, AddressOf Me.submit_Click Me.Controls.Add(update) ChildControlsCreated = True End Sub Private Sub submit_Click(ByVal sender As Object, _ ByVal e As EventArgs) ' Update the label string. If input.Text <> String.Empty Then Me.ContentText = Page.Server.HtmlEncode(input.Text) + "<br />" ' Clear the input textbox. input.Text = String.Empty DisplayContent.Text = Me.ContentText End If End Sub End Class End Namespace
using System; using System.Security.Permissions; using System.Web; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; namespace Samples.AspNet.CS.Controls { [AspNetHostingPermission(SecurityAction.Demand, Level=AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)] public class TextDisplayWebPart : WebPart { private String _contentText = null; TextBox input; Label DisplayContent; const string _subTitle = "Contoso, Ltd"; public TextDisplayWebPart() { this.AllowClose = false; } [ Personalizable(PersonalizationScope.User, true), WebBrowsable() ] public String ContentText { get { return _contentText; } set { _contentText = value; } } protected override void CreateChildControls() { Controls.Clear(); DisplayContent = new Label(); DisplayContent.BackColor = System.Drawing.Color.LightBlue; DisplayContent.Text = this.ContentText; this.Controls.Add(DisplayContent); input = new TextBox(); this.Controls.Add(input); Button update = new Button(); update.Text = "Set Label Content"; update.Click += new EventHandler(this.submit_Click); this.Controls.Add(update); ChildControlsCreated = true; } private void submit_Click(object sender, EventArgs e) { // Update the label string. if (input.Text != String.Empty) { this.ContentText = Page.Server.HtmlEncode(input.Text) + @"<br />"; // Clear the input textbox. input.Text = String.Empty; DisplayContent.Text = this.ContentText; } } } }
package Samples.AspNet.JSL.Controls; import System.*; import System.Security.Permissions.*; import System.Web.*; import System.Web.UI.WebControls.*; import System.Web.UI.WebControls.WebParts.*; /** @attribute AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal) */ /** @attribute AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal) */ public class TextDisplayWebPart extends WebPart { private String _contentText = null; private TextBox input; private Label displayContent; private String _subTitle = "Contoso, Ltd"; public TextDisplayWebPart() { this.set_AllowClose(false); } //TextDisplayWebPart /** @attribute Personalizable(PersonalizationScope.User, true) @attribute WebBrowsable() */ /** @property */ public String get_ContentText() { return _contentText; } //get_ContentText /** @property */ public void set_ContentText(String value) { _contentText = value; } //set_ContentText protected void CreateChildControls() { get_Controls().Clear(); displayContent = new Label(); displayContent.set_BackColor(System.Drawing.Color.get_LightBlue()); displayContent.set_Text(this.get_ContentText()); this.get_Controls().Add(displayContent); input = new TextBox(); this.get_Controls().Add(input); Button update = new Button(); update.set_Text("Set Label Content"); update.add_Click(new EventHandler(this.Submit_Click)); this.get_Controls().Add(update); set_ChildControlsCreated(true); } //CreateChildControls private void Submit_Click(Object sender, EventArgs e) { // Update the label string. if (!(input.get_Text().Equals(""))) { this.set_ContentText( this.get_Page().get_Server().HtmlEncode(input.get_Text()) + "<br />"); // Clear the input textbox. input.set_Text(""); displayContent.set_Text(this.get_ContentText()); } } //Submit_Click } //TextDisplayWebPart
Web ページの宣言型マークアップで、TextDisplayWebPart コントロールの 2 番目のインスタンスでは ChromeType プロパティ値が TitleOnly に設定されていることに注意してください。ブラウザでページを読み込むと、2 番目のコントロール インスタンスが最小化された状態で表示されます。2 番目のコントロールを展開すると、境界線なしのタイトル バーのみが表示されます。
<%@ page language="VB" %> <%@ register tagprefix="aspSample" Namespace="Samples.AspNet.VB.Controls" Assembly="TextDisplayWebPartVB" %> <html> <head id="Head1" runat="server"> </head> <body> <form id="Form1" runat="server"> <asp:webpartmanager id="WebPartManager1" runat="server" /> <asp:webpartzone id="WebPartZone1" runat="server" backcolor="#99cccc"> <parttitlestyle font-bold="true" forecolor="#ffffff" /> <partstyle borderwidth="1px" borderstyle="Solid" bordercolor="#81AAF2" /> <zonetemplate> <aspSample:TextDisplayWebPart runat="server" id="textwebpart" title = "Text Content WebPart" Description="A text content WebPart control." ChromeType="TitleAndBorder" width="350px" /> </zonetemplate> </asp:webpartzone> <asp:webpartzone id="WebPartZone2" runat="server" backcolor="#99cccc"> <parttitlestyle font-bold="true" forecolor="#ffffff" /> <partstyle borderwidth="1px" borderstyle="Solid" bordercolor="#81AAF2" /> <zonetemplate> <aspSample:TextDisplayWebPart runat="server" id="textwebpart2" title = "Text Content WebPart 2" Description="A text content WebPart control." ChromeType="TitleOnly" ChromeState="Minimized" width="350px" /> </zonetemplate> </asp:webpartzone> </form> </body> </html>
<%@ page language="C#" %> <%@ register tagprefix="aspSample" Namespace="Samples.AspNet.CS.Controls" Assembly="TextDisplayWebPartCS" %> <html> <head id="Head1" runat="server"> </head> <body> <form id="Form1" runat="server"> <asp:webpartmanager id="WebPartManager1" runat="server" /> <asp:webpartzone id="WebPartZone1" runat="server" backcolor="#99cccc"> <parttitlestyle font-bold="true" forecolor="#ffffff" /> <partstyle borderwidth="1px" borderstyle="Solid" bordercolor="#81AAF2" /> <zonetemplate> <aspSample:TextDisplayWebPart runat="server" id="textwebpart" title = "Text Content WebPart" Description="A text content WebPart control." ChromeType="TitleAndBorder" width="350px" /> </zonetemplate> </asp:webpartzone> <asp:webpartzone id="WebPartZone2" runat="server" backcolor="#99cccc"> <parttitlestyle font-bold="true" forecolor="#ffffff" /> <partstyle borderwidth="1px" borderstyle="Solid" bordercolor="#81AAF2" /> <zonetemplate> <aspSample:TextDisplayWebPart runat="server" id="textwebpart2" title = "Text Content WebPart 2" Description="A text content WebPart control." ChromeType="TitleOnly" ChromeState="Minimized" width="350px" /> </zonetemplate> </asp:webpartzone> </form> </body> </html>
<%@ page language="VJ#" %> <%@ register tagprefix="aspSample" Namespace="Samples.AspNet.JSL.Controls" Assembly="TextDisplayWebPartJSL" %> <html> <head id="Head1" runat="server"> </head> <body> <form id="Form1" runat="server"> <asp:webpartmanager id="WebPartManager1" runat="server" /> <asp:webpartzone id="WebPartZone1" runat="server" backcolor="#99cccc"> <parttitlestyle font-bold="true" forecolor="#ffffff" /> <partstyle borderwidth="1px" borderstyle="Solid" bordercolor="#81AAF2" /> <zonetemplate> <aspSample:TextDisplayWebPart runat="server" id="textwebpart" title = "Text Content WebPart" Description="A text content WebPart control." ChromeType="TitleAndBorder" width="350px" /> </zonetemplate> </asp:webpartzone> <asp:webpartzone id="WebPartZone2" runat="server" backcolor="#99cccc"> <parttitlestyle font-bold="true" forecolor="#ffffff" /> <partstyle borderwidth="1px" borderstyle="Solid" bordercolor="#81AAF2" /> <zonetemplate> <aspSample:TextDisplayWebPart runat="server" id="textwebpart2" title = "Text Content WebPart 2" Description="A text content WebPart control." ChromeType="TitleOnly" ChromeState="Minimized" width="350px" /> </zonetemplate> </asp:webpartzone> </form> </body> </html>

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- Part.ChromeTypeのページへのリンク