This documentation is archived and is not being maintained.

LinkButtonDesigner Class

Extends design-time behavior for the LinkButton Web server control.

For a list of all members of this type, see LinkButtonDesigner Members.


[Visual Basic]
Public Class LinkButtonDesigner
   Inherits TextControlDesigner
public class LinkButtonDesigner : TextControlDesigner
public __gc class LinkButtonDesigner : public TextControlDesigner
public class LinkButtonDesigner 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.


[Visual Basic] The following code example creates a custom designer class, named CustomLinkButtonDesigner, that derives from the LinkButtonDesigner class. It overrides the TextControlDesigner.GetDesignTimeHtml method. 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 Text property has already been set, 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.
              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.
              sampleButton.ForeColor = oldForeColor
          End Try
          designTimeHtml = MyBase.GetDesignTimeHtml()
      End If
      Return designTimeHTML

   End Function   
  End Class 
End Namespace

[Visual Basic] The following code example shows a simple class, named CustomLinkButton, that derives from the System.Web.UI.WebControls.LinkButtonBox class and is associated with the CustomLinkButtonDesigner class by the System.ComponentModel.Designer metadata attribute.

[Visual Basic] 
' The SampleLinkButton class that uses the 
' SampleLinkButtonDesigner class.    
 <DesignerAttribute( _
     GetType(Examples.AspNet.Design.SampleLinkButtonDesigner))> _
 Public Class SampleLinkButton
     Inherits LinkButton

     ' Add code here for a custom
     ' LinkButton class.

 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 Language Filter in the upper-left corner of the page.


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

LinkButtonDesigner Members | System.Web.UI.Design.WebControls Namespace | LinkButton