This documentation is archived and is not being maintained.

AdRotatorDesigner Class

Extends design-time behavior for the AdRotator Web server control.

For a list of all members of this type, see AdRotatorDesigner Members.


[Visual Basic]
Public Class AdRotatorDesigner
   Inherits ControlDesigner
public class AdRotatorDesigner : ControlDesigner
public __gc class AdRotatorDesigner : public ControlDesigner
public class AdRotatorDesigner extends ControlDesigner

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.


[Visual Basic] The following code example creates a designer class, named SimpleAdRotatorDesigner, that derives from the AdRotatorDesigner class and displays a custom SimpleAdRotator class at design time. The code checks whether the Image.AlternateText property of the object's image and the HyperLink.Target property of the object's link are empty. If the AlternateText property is set to an empty string, the code sets it in the designer to a placeholder string. If the Target property is set to an empty string, the code sets it to _self.

[Visual Basic] 
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.
                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

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

            Return html
        End Function
    End Class 
End Namespace

[Visual Basic] The following code example uses the System.ComponentModel.DesignerAttribute class to associate the SimpleAdRotato r class with the SimpleAdRotatorDesigner class.

[Visual Basic] 
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] No example is available for C#, C++, or JScript. To view a Visual Basic example, click the Language Filter button Language Filter in the upper-left corner of the page.


Namespace: System.Web.UI.Design.WebControls

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

Assembly: System.Design (in System.Design.dll)

See Also

AdRotatorDesigner Members | System.Web.UI.Design.WebControls Namespace | AdRotator