This documentation is archived and is not being maintained.

MenuDesigner Class

Provides design-time support in a visual designer for the Menu control.

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

public class MenuDesigner extends HierarchicalDataBoundControlDesigner implements IDataBindingSchemaProvider

The Menu class provides a hierarchical menu Web server control.

In a visual designer, when you switch from Source to Design view, the markup source code that describes the associated Menu control is parsed and a design-time version of the control is created on the design surface. When you switch back to Source view, the design-time control is persisted to markup and added to the existing markup for the Web page. The MenuDesigner class provides design-time support for Menu controls in a visual designer.

The ActionLists property returns a DesignerActionListCollection object, which typically contains an object that is derived from the DesignerActionList class for each level in the inheritance tree of the designer. The AutoFormats property returns a collection of formatting schemes for display in the Auto Format dialog box.

The TemplateGroups property returns a collection of template groups for the templates of the associated Menu control. The UsePreviewControl property always returns true, indicating that the designer creates a temporary copy of the associated Menu to generate the design-time markup.

The MenuDesigner class methods provide the following functionality:

  • The Initialize method prepares the designer to view, edit, and design the associated Menu control. The GetDesignTimeHtml method returns the markup that is used to render the associated Menu at design time.

  • The GetEmptyDesignTimeHtml method gets the markup that renders a placeholder for the associated control at design time when no markup is otherwise available. The GetErrorDesignTimeHtml method provides the markup that renders the associated control at design time when an error has occurred.

  • The DataBind method binds the associated Menu control to the design-time data source. The GetSampleDataSource method constructs a sample data source that can be used at design time for the associated control.

The following code example shows how to extend the MenuDesigner class to change the appearance of controls that are derived from the Menu control at design time.

The example derives the MyMenu class from the Menu. The MyMenu class is a copy of the Menu. The example also derives the MyMenuDesigner class from the MenuDesigner class, and then applies a DesignerAttribute attribute for the MyMenuDesigner on the MyMenu class.

The MyMenuDesigner overrides the following MenuDesigner members:

  • The GetDesignTimeHtml method to draw an orange, dotted border around the control to make its extent more visible.

  • The GetErrorDesignTimeHtml method to generate the markup for a placeholder that includes the error message, which is rendered in red, bold text.

  • The GetEmptyDesignTimeHtml to generate the markup for a placeholder that contains a message indicating that no menu items are defined.

  • The Initialize method to throw an ArgumentException exception, if the associated control is not a MyMenu object.

No code example is currently available or this language may not be supported.

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
Show: