次の方法で共有


AdRotatorDesigner クラス

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

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

System.Object
   System.ComponentModel.Design.ComponentDesigner
      System.Web.UI.Design.HtmlControlDesigner
         System.Web.UI.Design.ControlDesigner
            System.Web.UI.Design.WebControls.AdRotatorDesigner

Public Class AdRotatorDesigner
   Inherits ControlDesigner
[C#]
public class AdRotatorDesigner : ControlDesigner
[C++]
public __gc class AdRotatorDesigner : public ControlDesigner
[JScript]
public class AdRotatorDesigner extends ControlDesigner

スレッドセーフ

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

使用例

[Visual Basic] SimpleAdRotatorDesigner という名前のデザイナ クラスを作成するコード例を次に示します。このクラスは、 AdRotatorDesigner の派生クラスで、デザイン時にカスタムの 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

[Visual Basic] System.ComponentModel.DesignerAttribute クラスを使用して、 SimpleAdRotator クラスを SimpleAdRotatorDesigner クラスに関連付けるコード例を次に示します。

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

Namespace Examples.AspNet
    ' Create a class that uses the
    ' SimpleAdRotatorDesigner class
    ' to display it at design time.
    <Designer("Examples.AspNet.Design.SimpleAdRotatorDesigner", _
     "AdRotatorDesigner")> _
    Public Class SimpleAdRotator
      Inherits AdRotator
        ' Code for the custom class.
    End Class
End Namespace

[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 内)

参照

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