WebPartDesigner Class

Note: This class is new in the .NET Framework version 2.0.

Provides design-time visual support for WebPart controls.

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

public class WebPartDesigner : PartDesigner
public class WebPartDesigner extends PartDesigner
public class WebPartDesigner extends PartDesigner

The WebPartDesigner class provides the visual representation for WebPart controls at design time. It is derived from the PartDesigner class and adds validation to verify that the associated control is a WebPart control or derived type.

WebPartDesigner inherits a UsePreviewControl property from its parent that is always set to true. This causes the visual design environment to generate a View control to hold a temporary copy of the WebPart on the design surface; this copy is then persisted into markup. If you override the UsePreviewControl property to return false, the visual design environment generates markup directly from the actual WebPart control.

Web Parts designers generally act much like regular control designers; the principal methods for setting design-time appearance derive from the ControlDesigner class. Specifically, you can override the GetDesignTimeHtml method to change the design-time markup associated with the control. You can likewise override the GetErrorDesignTimeHtml and GetEmptyDesignTimeHtml methods to handle errors and empty strings (""), respectively.

The following code example shows the interaction between a WebPart control and its associated WebPartDesigner. The WebPart control contains a Calendar control from which the end user selects his or her birthday, a Button control to submit the selection, and a Label control to display a message on the user's birthday. The WebPartDesigner verifies that the associated control is of the expected type and then customizes the design-time rendering of said control. Note that the visual customizations of the designer are visible only at design time, whereas those of the associated control are visible at both run time and design time.

All the methods overridden in this example derive from the ControlDesigner base class. For other available members and their use, see System.Web.UI.Design.ControlDesigner.

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

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

.NET Framework

Supported in: 2.0