ButtonDesigner.GetDesignTimeHtml メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
デザイン時に関連付けられたコントロールを描画するために使用するマークアップを取得します。
public:
override System::String ^ GetDesignTimeHtml();
public override string GetDesignTimeHtml();
override this.GetDesignTimeHtml : unit -> string
Public Overrides Function GetDesignTimeHtml () As String
戻り値
デザイン時に Button を表示するために使用するマークアップを格納している String。
例
次のコード例では、 メソッドをオーバーライド GetDesignTimeHtml して生成されたマークアップを変更する方法を示します。
プロパティが BorderStyle 以前に設定されていない場合 (つまり、フィールド値を持つ NotSet )、 メソッドを GetDesignTimeHtml 呼び出すと、幅が 3 ピクセルの青い破線の境界線に設定され、デザインサーフェイスにその罫線が表示されます。 プロパティが BorderStyle 設定されている場合は、既存の境界線プロパティ値が表示されます。
通常、 は GetDesignTimeHtml 基本メソッド を呼び出します。このメソッドは、 ControlDesigner.GetDesignTimeHtml関連付けられたコントロールの メソッドを呼び出 Control.RenderControl してマークアップを生成します。
' Create a class that derives from ButtonDesigner
' and displays the custom SampleButton control
' on the design surface.
Imports System.Web.UI.Design
Imports System.Drawing
Imports System.ComponentModel
Imports System.Web.UI.WebControls
Imports System.Web.UI.Design.WebControls
Namespace Examples.AspNet
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
注釈
に表示可能な文字が含まれない場合、 メソッドはGetDesignTimeHtml、 プロパティを Button コントロールの プロパティにText置き換えますText。ID 次に、 メソッドはその GetDesignTimeHtml 基本メソッド を呼び出し、 ControlDesigner.GetDesignTimeHtmlメソッドを Control.RenderControl 呼び出してマークアップを生成します。
注意 (継承者)
メソッドをオーバーライドする場合、通常は選択したプロパティ値を GetDesignTimeHtml() 変更し、基本メソッドを呼び出してマークアップを生成し、プロパティを元の値に復元します。