次の方法で共有


ListControlDesigner.GetDesignTimeHtml メソッド

デザイン時にコントロールを表すために使用する HTML を取得します。

Overrides Public Function GetDesignTimeHtml() As String
[C#]
public override string GetDesignTimeHtml();
[C++]
public: String* GetDesignTimeHtml();
[JScript]
public override function GetDesignTimeHtml() : String;

戻り値

デザイン時にコントロールを表すために使用する HTML。

使用例

[Visual Basic] 次に示すのは、 GetDesignTimeHtml メソッドをオーバーライドするコード例です。このコードは、デザイン画面に表示される SimpleRadioButtonList クラスの HTML をカスタマイズするものです。コントロールの WebControl.BackColor プロパティが定義されていない場合、このコードはそのプロパティを Gainsboro に設定し、コントロールはその背景色で表示されます。コントロールが、 ListItem コントロールを含んでいるか、またはデータ連結されている場合、このコードは GetDesignTimeHtml メソッドの基本クラスの実装を呼び出します。それ以外の場合は、コントロールのリスト項目を定義するようユーザーに伝える文字列を表示します。その後、 GetDesignTimeHtml メソッドの基本クラスの実装が呼び出されます。

[Visual Basic] このコード例は、 ListControlDesigner クラスのトピックで取り上げているコード例の一部分です。

 
' Create HTML to display the control
' on the design surface.
Overrides Public Function GetDesignTimeHtml() As String
    
    Dim designTimeHtml As String
    
    ' Create variables to access the control's
    ' item collection and back color. 
    Dim items As ListItemCollection = simpleRadioButtonList.Items
    Dim oldBackColor As Color = simpleRadioButtonList.BackColor
    
    ' Check property values and render HTML
    ' on the design surface accordingly.
    Try
        If (Color.op_Equality(oldBackColor, Color.Empty)) Then
            simpleRadioButtonList.BackColor = Color.Gainsboro
        End If

        If (changedDataSource) Then
            items.Add( _
                "Updated to new data source: " & DataSource ".")
        End If

        designTimeHtml = MyBase.GetDesignTimeHtml()
    
    ' Catch any exceptions that occur.
    Catch ex As Exception
        MyBase.GetErrorDesignTimeHtml(ex)
    
    ' Set the properties to original state.
    Finally
        simpleRadioButtonList.BackColor = oldBackColor
        items.Clear()
    End Try
    
    Return designTimeHtml
End Function

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

必要条件

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

.NET Framework セキュリティ:

参照

ListControlDesigner クラス | ListControlDesigner メンバ | System.Web.UI.Design.WebControls 名前空間