This documentation is archived and is not being maintained.

AppearanceEditorPart Class

Provides an editor control that enables end users to edit several user interface (UI) properties on an associated WebPart control. This class cannot be inherited.

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

[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class AppearanceEditorPart : EditorPart
<asp:AppearanceEditorPart />

The AppearanceEditorPart class is an editor control that derives from the EditorPart class, and is used to edit properties that affect the appearance of an associated WebPart or other server control.

The AppearanceEditorPart control enables end users to edit several UI properties of a WebPart control. The type of control that appears in the page to edit each property value is listed in the adjacent cell of the following table.


Control used to edit property


A TextBox control is used to set the text for the title.


A DropDownList control is used to select what type of title-and-border option is used.


A DropDownList control is used to select the direction that content flows on the page.


A TextBox control is used to set a number for the height, and a DropDownList control is used to select the units.


A TextBox control is used to set a number for the height, and a DropDownList control is used to select the units.


A CheckBox control is used to indicate whether the control is hidden.

The AppearanceEditorPart control becomes visible only when a Web Parts page is in edit mode, and when a specific WebPart control has been selected for editing. The AppearanceEditorPart control, like all other EditorPart controls, resides in an EditorZone zone.

Important noteImportant Note:

An EditorZone zone can contain only EditorPart controls, and EditorPart controls cannot be placed in any other type of zone.

The AppearanceEditorPart class has a minimal set of properties. The Title property is used to get or set a string that is displayed as a title when the control is visible. The DefaultButton property sets the inherited property from the Panel control, so that the default control that receives the focus within the AppearanceEditorPart control is the same as the default in the base Panel control.

The AppearanceEditorPart class also has two important methods. The SyncChanges method overrides the base method from the EditorPart class. This method is critical because it enables getting the property values from the WebPart control it is editing and assigning them to the fields in the editor control. The ApplyChanges method is also important, because it takes the values set by the user in the editing controls, and updates those property values on the control being edited.

In most cases the AppearanceEditorPart control should be used in page persistence format by declaring an <asp:appearanceditorpart> element inside a <zonetemplate> element, which is in turn contained by an <asp:editorzone> element on a Web page.

To edit other properties and behavior of WebPart controls, you can use the other EditorPart controls supplied with the Web Parts control set. These controls include the BehaviorEditorPart, the LayoutEditorPart, and the PropertyGridEditorPart. The supplied EditorPart controls should provide most editing features required to edit WebPart controls, but you can also create a custom editor control by inheriting from the EditorPart class. For a code example, see the EditorPart class overview topic.


To improve accessibility, the AppearanceEditorPart control is rendered within a <fieldset> element. The <fieldset> element groups the related set of controls used for editing in the AppearanceEditorPart control, and it facilitates tabbed navigation among those controls for both visual (such as ordinary Web browsers) and speech-oriented user agents (such as screen-reading software).


The markup rendered by default for this control might not conform to accessibility standards such as the Web Content Accessibility Guidelines 1.0 (WCAG) priority 1 guidelines. For details about accessibility support for this control, see ASP.NET Controls and Accessibility.

How to: Set the Display Mode of a Web Parts PageBuilding ASP .NET Web Applications
How to: Set the Display Mode of a Web Parts PageBuilding ASP .NET Web Applications

The following code example demonstrates how to declare an AppearanceEditorPart control on a Web page, and enable it to edit several UI properties of a WebPart control. The code example has four parts:

  • A user control that enables you to change display modes on a Web Parts page.

  • A Web page that contains an EditorZone control and an AppearanceEditorPart control, along with a reference to a custom WebPart control.

  • A class that contains a custom WebPart control.

  • An explanation of how the example works when you load the page in a browser.

The source code for the user control comes from another topic. For this code example to work, you need to obtain the .ascx file for the user control from the Walkthrough: Changing Display Modes on a Web Parts Page topic, and place the file in the same folder as the .aspx page in this code example.

The second part of the code example is the Web page. It contains a declarative reference to an EditorZone control, with a child <zonetemplate> element that contains declarative references to an AppearanceEditorPart control. Also, the page references the custom WebPart control, using a Register directive for the assembly, and the <aspSample:TextDisplayWebPart> element for the control.

<%@ page language="c#" %>
<%@ register TagPrefix="uc1" 
  Src="DisplayModecs.ascx" %>
<%@ register tagprefix="aspSample" 
  Assembly="TextDisplayWebPartCS" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
<html xmlns="" >
  <head id="Head1" runat="server">
      Text Display WebPart with AppearanceEditorPart
    <form id="form1" runat="server">
      <asp:webpartmanager id="WebPartManager1" runat="server" />
      <uc1:DisplayModeMenu ID="DisplayModeMenu1" runat="server" />
      <asp:webpartzone id="zone1" runat="server">
            title = "Text Content WebPart" />          
      <asp:EditorZone ID="EditorZone1" runat="server">
          <asp:AppearanceEditorPart ID="AppearanceEditorPart1" 
            Title="Edit TextDisplayWebPart Properties" />

The third part of the code example is a custom WebPart class named TextDisplayWebPart, which is referenced in the 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 how to compile, see Walkthrough: Developing and Using a Custom Web Server Control.

using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Security.Permissions;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

namespace Samples.AspNet.CS.Controls
    Level = AspNetHostingPermissionLevel.Minimal)]
    Level = AspNetHostingPermissionLevel.Minimal)]
  public class TextDisplayWebPart : WebPart
    private String _contentText = null;
    TextBox input;
    Label DisplayContent;
    Literal lineBreak;

    [Personalizable(), WebBrowsable]
    public String ContentText
      get { return _contentText; }
      set { _contentText = value; }

    protected override void CreateChildControls()
      DisplayContent = new Label();
      DisplayContent.BackColor = Color.LightBlue;
      DisplayContent.Text = this.ContentText;

      lineBreak = new Literal();
      lineBreak.Text = @"<br />";

      input = new TextBox();
      Button update = new Button();
      update.Text = "Set Label Content";
      update.Click += new EventHandler(this.submit_Click);


    private void submit_Click(object sender, EventArgs e)
      // Update the label string. 
      if (input.Text != String.Empty)
        _contentText = input.Text + @"<br />";
        input.Text = String.Empty;
        DisplayContent.Text = this.ContentText;


When you load the page in a browser, you can select Edit Mode in the Display Mode drop-down control to switch to edit mode. You can click the verbs menu (the downward arrow) in the title bar of the TextDisplayWebPart control, and click Edit to edit the control. When the editing UI is visible, you can see the AppearanceEditorPart control. If you make some changes in the editing UI and click the Apply button, you can use the Display Mode drop-down list to return the page to browse mode and see the full effect of the editing changes.


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

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

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0