CheckBoxDesigner Class

Extends design-time behavior for the CheckBox Web server control.

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

public class CheckBoxDesigner : ControlDesigner
public class CheckBoxDesigner extends ControlDesigner
public class CheckBoxDesigner extends ControlDesigner

The CheckBoxDesigner class overrides the GetDesignTimeHtml method of the ControlDesigner class to ensure that the control is displayed with a meaningful representation at design time. If the Text property is empty, the GetDesignTimeHtml method of this class sets the Text property of the control to the Control.ID property of the control.

The following code example creates a custom designer class, named SampleCheckBoxDesigner, that inherits from the CheckBoxDesigner class. It overrides the GetDesignTimeHtml method. If the CheckBox.Text property has not been set previously, a call to this method sets it to a string and displays that string on the design surface. If the Text property has been set, the existing property value is displayed.

Imports System
'Imports System.Design
Imports System.Drawing
Imports System.ComponentModel
Imports System.Web.UI.WebControls
Imports System.Web.UI.Design
Imports System.Web.UI.Design.WebControls
'Imports Examples.AspNet

Namespace Examples.AspNet '.Design

    ' Create a class, named SampleCheckBoxDesigner, that overrides the
    ' GetDesignTimeHtml method to display the control on the design
    ' surface.

    Public Class SampleCheckBoxDesigner
        Inherits System.Web.UI.Design.WebControls.CheckBoxDesigner

        ' Override the GetDesignTimeHtml method to display a border on the 
        ' control if the BorderStyle property has not been set by the user.
        Public Overrides Function GetDesignTimeHtml() As String

            Dim sampleCheckBox As SampleCheckBox = CType(Component, _
            Dim designTimeHtml As String = Nothing

            ' Check the control's BorderStyle property.
            If (sampleCheckBox.BorderStyle = BorderStyle.NotSet) Then

                ' Save the current value of the BorderStyle property.
                Dim oldBorderStyle As BorderStyle = _

                ' Change the value of the BorderStyle property and 
                ' generate the design-time HTML.
                    sampleCheckBox.BorderStyle = BorderStyle.Groove
                    designTimeHtml = MyBase.GetDesignTimeHtml()

                    ' If an exception occurs, call the GetErrorDesignTimeHtml
                    ' method.
                Catch ex As Exception
                    designTimeHtml = GetErrorDesignTimeHtml(ex)

                    ' Restore the BorderStyle property to its original value.
                    sampleCheckBox.BorderStyle = oldBorderStyle
                End Try

                designTimeHtml = MyBase.GetDesignTimeHtml()
            End If

            Return designTimeHtml
        End Function
    End Class
End Namespace

The following code example is a simple class, named SampleCheckBox, that inherits from the CheckBox class and is associated with the SampleCheckBoxDesigner class by the DesignerAttribute class.

Namespace Examples.AspNet

    ' The SampleCheckBox class that uses the SampleCheckBoxDesigner class.
    <Designer(GetType( _
        Examples.AspNet.SampleCheckBoxDesigner))> _
    Public Class SampleCheckBox
        Inherits CheckBox
        ' To customize the CheckBox class, insert code here.
    End Class

End Namespace

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 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, 1.1, 1.0