CheckBoxDesigner.GetDesignTimeHtml Method
Gets the HTML that is used to represent the control at design time.
[Visual Basic] Overrides Public Function GetDesignTimeHtml() As String [C#] public override string GetDesignTimeHtml(); [C++] public: String* GetDesignTimeHtml(); [JScript] public override function GetDesignTimeHtml() : String;
Return Value
The HTML that is used to represent the control at design time.
Remarks
This method sets the Text property of the control to the Control.ID property of the control, if the Text property is empty.
Example
[Visual Basic] 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.
[Visual Basic]
' Override the GetDesignTimeHtml method to display
' display a border on the control if the BorderStyle
' property has not been set by the user.
<System.Security.Permissions.SecurityPermission( _
System.Security.Permissions.SecurityAction.Demand, _
Flags := System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)> _
Public Class SampleCheckBoxDesigner
Inherits CheckBoxDesigner
' Override the GetDesignTimeHtml method.
Public Overrides Function GetDesignTimeHtml() As String
Dim sampleCheckBox As SampleCheckBox = CType(Component, SampleCheckBox)
Dim designTimeHtml As String = Nothing
' Check the control's BorderStyle property
' to conditionally render design-time HTML.
If (sampleCheckBox.BorderStyle = BorderStyle.NotSet) Then
' Create variables to hold current property settings.
Dim oldBorderStyle As BorderStyle = sampleCheckBox.BorderStyle
' Set properties and the design-time HTML.
Try
sampleCheckBox.BorderStyle = BorderStyle.Groove
designTimeHtml = MyBase.GetDesignTimeHtml()
' If an exception occurs, call the GetErrorDesignTimeHtml
' method.
Catch ex As Exception
designTimeHtml = GetErrorDesignTimeHtml(ex)
' Return properties to their original settings.
Finally
sampleCheckBox.BorderStyle = oldBorderStyle
End Try
Else
designTimeHtml = MyBase.GetDesignTimeHtml()
End If
Return designTimeHTML
End Function
[C#, C++, JScript] No example is available for C#, C++, or JScript. To view a Visual Basic example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family
.NET Framework Security:
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries From Partially Trusted Code
See Also
CheckBoxDesigner Class | CheckBoxDesigner Members | System.Web.UI.Design.WebControls Namespace