CheckBoxDesigner.GetDesignTimeHtml Method ()


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Gets the markup that is used to represent the control at design time.

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

public override string GetDesignTimeHtml()

Return Value

Type: System.String

The markup that is used to represent the control at design time.

If the Text property is empty or consists only of white space, then the generated HTML contains the ID of the check box control; otherwise, the generated HTML contains the contents of the control's Text property.

Override this method to change the generated HTML.

The following code example 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 already been set, the existing property value is displayed.

' 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

.NET Framework
Available since 1.1
Return to top