This documentation is archived and is not being maintained.

AdRotator Constructor

Initializes a new instance of the AdRotator class.

[Visual Basic]
Public Sub New()
[C#]
public AdRotator();
[C++]
public: AdRotator();
[JScript]
public function AdRotator();

Remarks

Use this constructor to create and initialize a new instance of the AdRotator class.

Example

[Visual Basic, C#, JScript] The following example demonstrates how to create and initialize a new instance of the AdRotator class. The new AdRotator control is then added to the Control.Controls collection of a PlaceHolder control and displayed on the Web Forms page.

[Visual Basic] 

<%@ Page Language="VB" AutoEventWireup="True" %>

<html>
<head>

   <script runat="server">

      Sub Page_Load(sender As Object, e As EventArgs) 
      
         ' Create an AdRotator control.
         Dim rotator As AdRotator = New AdRotator()

         ' Set the control's properties.
         rotator.AdvertisementFile = "Ads.xml"

         ' Add the control to the Controls collection of a 
         ' PlaceHolder control.  
         myPlaceHolder.Controls.Add(rotator)
      
      End Sub

   </script>

</head>

<body>

   <form runat="server">

      <h3>AdRotator Constructor Example</h3>

      <asp:Placeholder id=myPlaceHolder 
           runat="server"/>

   </form>

</body>
</html>


[C#] 
<%@ Page Language="C#" AutoEventWireup="True" %>

<html>
<head>

   <script runat="server">

      void Page_Load(Object sender, EventArgs e) 
      {
         // Create an AdRotator control.
         AdRotator rotator = new AdRotator();

         // Set the control's properties.
         rotator.AdvertisementFile = "Ads.xml";

         // Add the control to the Controls collection of a 
         // PlaceHolder control.  
         myPlaceHolder.Controls.Add(rotator);
      }

   </script>

</head>

<body>

   <form runat="server">

      <h3>AdRotator Constructor Example</h3>

      <asp:Placeholder id=myPlaceHolder 
           runat="server"/>

   </form>

</body>
</html>


[JScript] 

<%@ Page Language="JScript" AutoEventWireup="True" %>

<html>
<head>

   <script runat="server">

      function Page_Load(sender, e : EventArgs) 
      {
         // Create an AdRotator control.
         var rotator : AdRotator = new AdRotator();

         // Set the control's properties.
         rotator.AdvertisementFile = "Ads.xml";

         // Add the control to the Controls collection of a 
         // PlaceHolder control.  
         myPlaceHolder.Controls.Add(rotator);
      }

   </script>

</head>

<body>

   <form runat="server">

      <h3>AdRotator Constructor Example</h3>

      <asp:Placeholder id=myPlaceHolder 
           runat="server"/>

   </form>

</body>
</html>

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

Requirements

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

See Also

AdRotator Class | AdRotator Members | System.Web.UI.WebControls Namespace | Control.Controls | Literal

Show: