PartChromeState Enumeration
Collapse the table of content
Expand the table of content

PartChromeState Enumeration


Specifies whether a control and the border surrounding it are in a normal or minimized state.

Namespace:   System.Web.UI.WebControls.WebParts
Assembly:  System.Web (in System.Web.dll)

public enum PartChromeState

Member nameDescription

A control and border in a collapsed or minimized state.


A control and border in a normal state.

The PartChromeState enumeration represents the possible visible states that a Web Parts control and its surrounding border can be in.

The following code examples demonstrate the declarative use of the PartChromeState enumeration by using a custom WebPart control referenced in an ASP.NET Web page. For the code example to run, you must compile this source code. You can compile it explicitly and put the resulting assembly in your Web site's Bin folder or the global assembly cache. Alternatively, you can put the source code in your site's App_Code folder, where it will be dynamically compiled at run time. For a walkthrough that demonstrates both methods of compiling, see Walkthrough: Developing and Using a Custom Web Server Control.

The first part of the example contains the code for the custom control, named TextDisplayWebPart. Because the control derives from WebPart, it also inherits the common properties that the Part class provides, including the ChromeState property, which uses the PartChromeState enumeration as its return type.

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
  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),
    public String ContentText
      get { return _contentText; }
      set { _contentText = value; }

    protected override void CreateChildControls()
      DisplayContent = new Label();
      DisplayContent.BackColor = 
      DisplayContent.Text = this.ContentText;
      input = new TextBox();
      Button update = new Button();
      update.Text = "Set Label Content";
      update.Click += new EventHandler(this.submit_Click);
      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;

Note that in the declarative markup for the Web page, the second instance of the TextDisplayWebPart control sets its ChromeState property. After you load the page in a browser, the second control instance appears minimized.

.NET Framework
Available since 2.0
Return to top
© 2015 Microsoft