Freigeben über


ASP.NET Control Designers Overview 

ASP.NET includes enhanced support for creating designers for Web server controls. Designers enable you to build a design-time user interface (UI) for a control, so that developers can configure your control's properties and content in a visual design tool such as Microsoft Visual Studio 2005. For background information on the design-time architecture and features provided by the .NET Framework, see Extending Design-Time Support.

This introduction explains the features of ASP.NET control designers, basic designer classes and their functionality, and scenarios for working with designers.

Designer Features

While ASP.NET version 2.0 continues to support the control designer architecture from the previous version, it has added significant improvements.

  • Region-based editing. Regions are editable areas in the design-time view of a control. This feature offers WYSIWYG editing of a control's contents at design time.

  • Action lists. Action lists are menus of tasks that the page developer of a control can use in the design-time UI. For example, the design-time view of your control could provide a menu of available tasks, including a task to format the control automatically.

  • Data source and data-bound designers. Data source control designers allow the page developer to configure data source controls. Data-bound control designers allow the page developer to configure data-bound controls. Features are available to implement cross communication between the data source and data-bound designers. For an example of a data source control designer, see DataSourceDesigner. For an example of a data-bound control designer, see HierarchicalDataBoundControlDesigner.

  • Simplified template editing. The model for creating a UI for design-time editing of templated controls (such as GridView) has been drastically simplified and modified so that the control developer can choose to perform his or her own template editing with regions. For an example, see Templated Server Control Example.

  • Simplified object model. The object model for working with design-time rendering is simplified, so that the only significant issue a developer has to be concerned with is producing design-time HTML. Several new base classes provide access to the simplified object model: ControlDesigner, ContainerControlDesigner, and CompositeControlDesigner.

  • Subscription to host services. A control designer can subscribe to and use various services provided by the host environment. For example, a control designer can use Visual Studio 2005 services to provide access to data, provide access to configuration, add controls to a page programmatically at design time, handle click events in the designer, paint on the design surface, and access other services such as designer-state.

Designer Classes

A control designer enables design-time rendering for a Web server control by acting as a mediator between the run-time control and the host environment. Within the host environment, designers provide the following functionality to help you create a design-time UI for users of your controls:

  • Design-time rendering and content. A control designer enables multiple kinds of rendering, both simple and complex. Region-based editing and template editing are examples of the kinds of design-time UI you can provide for a control. You can also provide column editing or multiple run-time views on a control, so a developer working with the control at design time can choose from a set of options as to how the control is rendered at run time.

  • Other design-time classes. Besides the designer classes, there are type converter classes that associate with a type or property and perform type conversions (such as string-to-value). There are also UI type editor classes that provide a specialized UI for editing a property. For example, the color picker drop-down list in a property grid enables you to select a color for a color property on a Web control. You can also create a specialized component editor, which is a class that provides editing for the properties of a control as a whole.

  • Persistence of the associated control's data. The inner properties and content of a control can be persisted, so that the control and its child controls maintain state in the design-time environment. This is controlled by how the configured control is defined in the markup.

When you create control designers for your Web server controls, there are several base classes you are likely to use:

Scenarios for Working with Designers

There are two common scenarios in which you might work with control designers: developing custom controls, and developing visual design tools.

If you develop custom Web server controls, you can create an associated designer to enhance a page developer's ability to configure the control at design time. This scenario is especially useful if your control might be reused by a number of page developers. For example, you might create a custom chart control. If you provide an associated control designer, different intranet page developers could each configure a control on a page with a different style.

If you develop a visual Web design tool, similar to Visual Studio 2005 or Microsoft FrontPage, you can utilize the control designer hosting components. This enables your tool to provide services and interact with control designers, in order to provide design-time rendering for custom controls.

For more information about the .NET Framework designer architecture, see Design-Time Architecture. For details on creating your own designer for a custom Web server control, see Walkthrough: Creating a Basic Control Designer for a Web Server Control.

Supporting Multiple Development Tools

Microsoft Visual Web Developer supports all the features discussed in this topic, but other developer tools might not. Some examples of features that might not be supported are:

See Also

Concepts

Design-Time Architecture
Sample Control Designer with Action Lists and Services

Other Resources

Design-Time Support for ASP.NET Web Pages
Extending Design-Time Support