Button Web サーバー コントロールのデザイン時の動作を拡張します。
この型のすべてのメンバの一覧については、ButtonDesigner メンバ を参照してください。
System.Object
System.ComponentModel.Design.ComponentDesigner
System.Web.UI.Design.HtmlControlDesigner
System.Web.UI.Design.ControlDesigner
System.Web.UI.Design.WebControls.ButtonDesigner
Public Class ButtonDesigner
Inherits ControlDesigner
[C#]
public class ButtonDesigner : ControlDesigner
[C++]
public __gc class ButtonDesigner : public ControlDesigner
[JScript]
public class ButtonDesigner extends ControlDesigner
スレッドセーフ
この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。
解説
Text プロパティが空の場合、 ButtonDesigner クラスの GetDesignTimeHtml メソッドは、コントロールの Text プロパティをそのコントロールの ID プロパティに設定します。ただし、オーバーライドされた場合は例外です。
使用例
[Visual Basic] CustomButtonDesigner という名前のカスタム デザイナ クラスを ButtonDesigner クラスから継承して作成するコード例を次に示します。このカスタム クラスは GetDesignTimeHtml メソッドをオーバーライドします。 Button.Text プロパティが設定済みでない場合は、このメソッドを呼び出すと、プロパティに文字列が設定され、デザイン画面にその文字列が表示されます。 Text プロパティに値が既に設定されている場合は、その値が表示されます。
' Create a class that derives from ButtonDesigner
' that displays the custom SampleButton control
' on a design surface.
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
' <System.Security.Permissions.SecurityPermission( _
' System.Security.Permissions.SecurityAction.Demand, _
' Flags:=System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)> _
Public Class SampleButtonDesigner
Inherits ButtonDesigner
' Override the GetDesignTimeHtml method.
Public Overrides Function GetDesignTimeHtml() As String
Dim sampleButton As SampleButton = CType(Component, SampleButton)
Dim designTimeHtml As String = Nothing
' Check the control's BorderStyle property
' to conditionally render design-time HTML.
If (sampleButton.BorderStyle = BorderStyle.NotSet) Then
' Create variables to hold current property settings.
Dim oldBorderStyle As BorderStyle = sampleButton.BorderStyle
Dim oldBorderWidth As Unit = sampleButton.BorderWidth
Dim oldBorderColor As Color = sampleButton.BorderColor
' Set properties and the design-time HTML.
Try
sampleButton.BorderStyle = BorderStyle.Dashed
sampleButton.BorderWidth = Unit.Pixel(3)
sampleButton.BorderColor = Color.Blue
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.BorderStyle = oldBorderStyle
sampleButton.BorderWidth = oldBorderWidth
sampleButton.BorderColor = oldBorderColor
End Try
Else
designTimeHtml = MyBase.GetDesignTimeHtml()
End If
Return designTimeHTML
End Function
End Class
End Namespace
[Visual Basic] CustomButton という名前の単純なクラスを Button クラスから継承して作成するコード例を次に示します。このクラスは、 DesignerAttribute クラスにより CustomButtonDesigner クラスと関連付けられます。
<DesignerAttribute( _
GetType(Examples.AspNet.Design.SampleButtonDesigner))> _
Public Class SampleButton
Inherits Button
' Include code here for a custom
' class that inherits from Button.
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 内)
参照
ButtonDesigner メンバ | System.Web.UI.Design.WebControls 名前空間 | Button