System.Web.UI.Design.SupportsPreviewControlAttribute Class

Indicates whether a control designer requires a preview instance of the control at design time. This class cannot be inherited.

See Also: SupportsPreviewControlAttribute Members


public sealed class SupportsPreviewControlAttribute : Attribute


Apply the System.Web.UI.Design.SupportsPreviewControlAttribute attribute to a control designer class to indicate the type of preview control that is supported by the control designer. Use this attribute to change a preview control for design-time rendering without affecting the actual persisted instance of the associated control.

Typically, you specify the System.Web.UI.Design.SupportsPreviewControlAttribute when declaring a custom designer class that is derived from the System.Web.UI.Design.ControlDesigner class. The value of the SupportsPreviewControlAttribute.SupportsPreviewControl property for the System.Web.UI.Design.SupportsPreviewControlAttribute attribute determines the behavior for the ControlDesigner.UsePreviewControl and ControlDesigner.ViewControl members in the base System.Web.UI.Design.ControlDesigner class.

Set the SupportsPreviewControlAttribute.SupportsPreviewControl property to true to indicate that the designer uses a temporary copy of the associated control to generate the design-time HTML. Changes to the temporary control are not persisted.

Set the SupportsPreviewControlAttribute.SupportsPreviewControl property to false to indicate that the designer returns the control instance, specifically the System.ComponentModel.Design.ComponentDesigner.Component property, from the ControlDesigner.ViewControl method. Changes to the control object are persisted.

For example, the System.Web.UI.Design.WebControls.CalendarDesigner class is marked with the System.Web.UI.Design.SupportsPreviewControlAttribute set to true. The designer uses the preview control with the automatic style formatting task, which allows the user to preview various autoformat styles that can be applied to the calendar. As the user selects different autoformat styles in the user interface, the selected style scheme is applied to the preview control. Applying a new style to the preview control does not change the scheme that is applied to the instance of the System.Web.UI.WebControls.Calendar control in the designer.

If the System.Web.UI.Design.SupportsPreviewControlAttribute is not specified in the control designer declaration, the System.Web.UI.Design.ControlDesigner behavior is equivalent to specifying the SupportsPreviewControlAttribute.SupportsPreviewControl as false.


Designer classes derived from the System.Web.UI.Design.ControlDesigner class can override the ControlDesigner.UsePreviewControl and ControlDesigner.ViewControl members, and ignore the System.Web.UI.Design.SupportsPreviewControlAttribute attribute. To determine the expected behavior for ControlDesigner.ViewControl and ControlDesigner.UsePreviewControl, see the reference documentation for the derived control designer class.

For general information about using attributes, see Attributes Overview and Extending Metadata Using Attributes. For more information about design-time attributes, see Attributes and Design-Time Support.


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