HyperLinkDesigner.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 determines whether the Text and NavigateUrl properties of the HyperLink control are data bound. If the property is data bound, this method sets the value of the Text property to "DataBound" and if the NavigateUrl property is data bound, this method sets the value of the property to a text string so the control will have an appearence like a working hyperlink.
Example
[Visual Basic] The following code example creates a class, named CustomHyperLinkDesigner, that inherits the HyperLinkDesigner class and displays the CustomHyperLink class at design time. It overrides the GetDesignTimeHtml method to ensure that a customized value is displayed for the Text property on the design surface, even if its value has not been set by the user.
[Visual Basic] This code example is part of a larger example provided for the HyperLinkDesigner class.
[Visual Basic]
' Create a class, named CustomHyperLinkDesigner,
' that derives from the HyperLinkDesigner class.
' This new class displays the custom class,
' CustomHyperLink at design time.
Public Class CustomHyperLinkDesigner
Inherits HyperLinkDesigner
' Override the GetDesignTimeHtml method to set the
' string property values of the CustomHyperLink class
' so that they will display at design time.
Public Overrides Function GetDesignTimeHtml() As String
Dim hl As CustomHyperLink = CType(Component, CustomHyperLink)
Dim designTimeHtml As String = Nothing
Dim text As String = hl.Text
Dim noText As Boolean = (text.Trim().Length = 0)
Try
If noText Then
hl.Text = "Click here."
End If
designTimeHtml = MyBase.GetDesignTimeHtml()
Catch e As New Exception()
designTimeHtml=GetErrorDesignTimeHtml(e)
Finally
If noText Then
hl.Text = text
End If
End Try
If ((designTimeHtml = Nothing) Or (designTimeHtml.Length = 0)) Then
designTimeHtml = GetEmptyDesignTimeHtml()
End If
Return designTimeHtml
End Function
End Class
[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
HyperLinkDesigner Class | HyperLinkDesigner Members | System.Web.UI.Design.WebControls Namespace | HyperLink