BaseValidatorDesigner.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.
Example
[Visual Basic] The following code example creates a designer class, named SimpleCompareValidatorDesigner, that derives from the BaseValidatorDesigner class and is used to display a class, named CustomAdRotator, at design time. It overrides the GetDesignTimeHtml to set the the validator's BaseValidator.ErrorMessage and BaseValidator.Display property values at design time. If the code in the Try block changes any property values, the code in the Finally block returns them to their original values.
[Visual Basic]
Imports System
Imports System.ComponentModel
Imports System.Web
Imports System.Web.UI
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 that derives from the
' BaseValidatorDesigner class that will
' display a CustomCompareValidator class
' at design time.
Public Class SimpleCompareValidatorDesigner
Inherits BaseValidatorDesigner
' Extend the GetDesignTimeHtml functionality to
' alter the design-time ForeColor if the Text
' property is defined.
Overrides Public Function GetDesignTimeHtml() As String
Dim cv As SimpleCompareValidator = _
CType(Component, SimpleCompareValidator)
Dim designTimeHtml As String
' Check the control's BorderStyle property
' to conditionally render design-time HTML.
If (cv.BorderStyle = BorderStyle.NotSet) Then
' Create variables to hold current property settings.
Dim oldBorderStyle As BorderStyle = cv.BorderStyle
' Set properties and the design-time HTML.
Try
cv.BorderStyle = BorderStyle.Solid
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
cv.BorderStyle = oldBorderStyle
End Try
Else
designTimeHtml = MyBase.GetDesignTimeHtml()
End If
Return designTimeHtml
End Function
End Class
End Namespace
[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
BaseValidatorDesigner Class | BaseValidatorDesigner Members | System.Web.UI.Design.WebControls Namespace