次の方法で共有


AdRotatorDesigner.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] SimpleAdRotatorDesigner という名前のデザイナ クラスを作成するコード例を次に示します。このクラスは、 AdRotatorDesigner の派生クラスで、デザイン時にカスタムの SimpleAdRotator クラスを表示します。このコードは、 GetDesignTimeHtml メソッドをオーバーライドして、デザイン画面で SimpleAdRotator のインスタンスの Image.AlternateText プロパティと HyperLink.Target プロパティの値を設定します。 AlternateText プロパティに空文字列が設定されている場合、このプロパティはデザイナ内でプレースホルダ文字列に設定されます。 Target プロパティに空文字列が設定されている場合、このプロパティは _self に設定されます。

 
Imports System.ComponentModel
Imports System.Web.UI.WebControls
Imports System
Imports System.Web.UI
Imports System.Web.UI.Design
Imports System.Web.UI.Design.WebControls
Imports Examples.AspNet

Namespace Examples.AspNet.Design
  ' Create a class that derives from the AdRotatorDesigner class.
    Public Class SimpleAdRotatorDesigner
      Inherits AdRotatorDesigner
   
        ' Override the GetDesignTimHtml method to create
        ' HTML to display for the control at design time.
        Public Overrides Function GetDesignTimeHtml() As String
      
            Dim rotator As SimpleAdRotator = CType(Component, SimpleAdRotator)
      
      
            ' Create the link and image for the rotator.
            Dim adLink As HyperLink = New HyperLink()
            Dim adImage As Image = New Image()
            Dim html As String

            Dim originalAltText As String = rotator.ID 
            Dim originalTarget As String = rotator.Target

            ' Set alternate text and target values 
            ' to display on the design surface.
            Try
                If originalAltText = String.Empty Then
                    adImage.AlternateText = "Ad Image"
                End If

                If originalTarget = String.Empty Then
                    adLink.Target= "_self"
                End If
                html = MyBase.GetDesignTimeHtml()
            Catch ex As Exception
                GetErrorDesignTimeHtml(ex)

            ' Return the property values to original.
            Finally
                adImage.AlternateText = originalAltText
                adLink.Target = originalTarget
            End Try

            Return html
     
        End Function
    End Class 
End Namespace

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

必要条件

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

.NET Framework セキュリティ:

参照

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