This documentation is archived and is not being maintained.

TextControlDesigner.GetDesignTimeHtml Method

Gets the HTML that is used to represent the associated 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 used to represent the control at design time.

Remarks

The TextControlDesigner class overrides the ControlDesigner.GetDesignTimeHtml method to ensure that a non-empty Text property value is present when rendering the control for display on the design surface. This ensures a meaningful representation of the control at design time. This method sets any empty Text property on the control to the ID property of the control.

Example

[Visual Basic] The following code example creates a custom designer class, named CustomLinkButtonDesigner, that derives from the LinkButtonDesigner class. It overrides the GetDesignTimeHtml method, which the LinkButtonDesigner class inherits from the TextControlDesigner class. If the LinkButton.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 LinkButton.Text property has been set already, the existing property value is displayed.

[Visual Basic] 
' Create a class that derives from LinkButtonDesigner
' that displays the custom SampleLinkButton control
' on a design surface.
Imports System
Imports System.Design
Imports System.Drawing
Imports System.ComponentModel
Imports System.Web.UI.WebControls
Imports System.Web.UI.Design.WebControls
Imports Examples.AspNet

Namespace Examples.AspNet.Design

 <System.Security.Permissions.SecurityPermission( _
   System.Security.Permissions.SecurityAction.Demand, _
    Flags:=System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)> _
Public Class SampleLinkButtonDesigner
   Inherits LinkButtonDesigner
   
 
   ' Override the GetDesignTimeHtml method.
   Public Overrides Function GetDesignTimeHtml() As String

      Dim sampleButton As SampleLinkButton = CType(Component, SampleLinkButton)
      Dim designTimeHtml As String = Nothing      
      
      ' Check the control's BorderStyle property
      ' to conditionally render design-time HTML.
      If (Color.op_Equality(sampleButton.ForeColor, Color.Empty)) Then

          ' Create a variable to hold current property settings.
          Dim oldForeColor As Color = sampleButton.ForeColor
                    
          ' Set properties and the design-time HTML.
          Try
              sampleButton.ForeColor = Color.DarkGreen
              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
              sampleButton.ForeColor = oldForeColor
          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 Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

.NET Framework Security: 

See Also

TextControlDesigner Class | TextControlDesigner Members | System.Web.UI.Design Namespace

Show: