LabelDesigner Class
Extends design-time behavior for the Label Web server control.
For a list of all members of this type, see LabelDesigner Members.
System.Object
System.ComponentModel.Design.ComponentDesigner
System.Web.UI.Design.HtmlControlDesigner
System.Web.UI.Design.ControlDesigner
System.Web.UI.Design.TextControlDesigner
System.Web.UI.Design.WebControls.LabelDesigner
[Visual Basic] Public Class LabelDesigner Inherits TextControlDesigner [C#] public class LabelDesigner : TextControlDesigner [C++] public __gc class LabelDesigner : public TextControlDesigner [JScript] public class LabelDesigner extends TextControlDesigner
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Example
[Visual Basic] The following code example shows a custom designer that derives from the LabelDesigner class. It overrides the TextControlDesigner.GetDesignTimeHtml method to determine if the BorderStyle property has been set on the instance of the SampleLabel class that the designer displays. If it has not been set, the method sets it to the Dashed enumeration value of the BorderStyle enumeration. You can perform similar steps to customize how a control appears on the design surface by default.
[Visual Basic]
Imports System
Imports System.Design
Imports System.Drawing
Imports System.ComponentModel
Imports System.Diagnostics
Imports System.Web.UI.WebControls
Imports System.Web.UI.Design.WebControls
Imports Examples.AspNet
Namespace Examples.AspNet.Design
Public Class SampleLabelDesigner
Inherits LabelDesigner
' Override the GetDesignTimeHtml method.
Public Overrides Function GetDesignTimeHtml() As String
Dim sampleLabel As SampleLabel = CType(Component, SampleLabel)
Dim designTimeHtml As String = Nothing
' Check the control's BorderStyle property
' to conditionally render design-time HTML.
If (sampleLabel.BorderStyle = BorderStyle.NotSet) Then
' Create variables to hold current property settings.
Dim oldBorderStyle As BorderStyle = sampleLabel.BorderStyle
' Set properties and the design-time HTML.
Try
sampleLabel.BorderStyle = BorderStyle.Dashed
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
sampleLabel.BorderStyle = oldBorderStyle
End Try
Else
designTimeHtml = MyBase.GetDesignTimeHtml()
End If
Return designTimeHTML
End Function
End Class
End Namespace
[Visual Basic] The following code example shows a custom control, named SampleLabel, which derives from the Label class. The examples uses the SampleLabelDesigner class to display the control on a design surface.
[Visual Basic]
' Create a SampleLabel class that derives from
' the Label class and is associated with the
' CustomLabelDesigner class by incuding a
' reference to the designer in the Designer
' metadata attribute.
Namespace Examples.AspNet
<DesignerAttribute( _
GetType(Examples.AspNet.Design.SampleLabelDesigner))> _
Public Class SampleLabel
Inherits Label
' Include code here for a custom
' class that inherits from Button.
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
Namespace: System.Web.UI.Design.WebControls
Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family
Assembly: System.Design (in System.Design.dll)
See Also
LabelDesigner Members | System.Web.UI.Design.WebControls Namespace | Label