次の方法で共有


LinkButtonDesigner クラス

LinkButton Web サーバー コントロールに対してデザイン時の動作を拡張します。

この型のすべてのメンバの一覧については、LinkButtonDesigner メンバ を参照してください。

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.LinkButtonDesigner

Public Class LinkButtonDesigner
   Inherits TextControlDesigner
[C#]
public class LinkButtonDesigner : TextControlDesigner
[C++]
public __gc class LinkButtonDesigner : public TextControlDesigner
[JScript]
public class LinkButtonDesigner extends TextControlDesigner

スレッドセーフ

この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。

使用例

[Visual Basic] CustomLinkButtonDesigner という名前のカスタム デザイナ クラスを LinkButtonDesigner クラスから継承して作成するコード例を次に示します。このカスタム クラスは、 TextControlDesigner.GetDesignTimeHtml メソッドをオーバーライドします。 LinkButton.Text プロパティが設定済みでない場合は、このメソッドを呼び出すと、プロパティに文字列が設定され、デザイン画面にその文字列が表示されます。 Text プロパティに値が既に設定されている場合は、その値が表示されます。

 
' 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

[Visual Basic] CustomLinkButton という名前の単純なクラスを System.Web.UI.WebControls.LinkButtonBox クラスから継承して作成するコード例を次に示します。このクラスは、 System.ComponentModel.Designer メタデータ属性により CustomLinkButtonDesigner クラスと関連付けられます。

 
' 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] C#、C++、および JScript のサンプルはありません。Visual Basic のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

名前空間: System.Web.UI.Design.WebControls

プラットフォーム: Windows 2000, Windows XP Professional, Windows Server 2003 ファミリ

アセンブリ: System.Design (System.Design.dll 内)

参照

LinkButtonDesigner メンバ | System.Web.UI.Design.WebControls 名前空間 | LinkButton