AdRotator Konstruktor

Definition

Initialisiert eine neue Instanz der AdRotator-Klasse.

public:
 AdRotator();
public AdRotator ();
Public Sub New ()

Beispiele

Im folgenden Codebeispiel wird veranschaulicht, wie Sie eine neue Instanz der AdRotator Klasse erstellen und initialisieren. Das neue AdRotator Steuerelement wird dann der Control.Controls Auflistung eines PlaceHolder Steuerelements hinzugefügt und auf der seite Web Forms angezeigt.

Hinweis

Im folgenden Codebeispiel wird das Einzeldateicodemodell verwendet und funktioniert möglicherweise nicht ordnungsgemäß, wenn sie direkt in eine CodeBehind-Datei kopiert werden. Dieses Codebeispiel muss in eine leere Textdatei kopiert werden, die über eine ASPX-Erweiterung verfügt. Weitere Informationen zum Web Forms Codemodell finden Sie unter ASP.NET Web Forms Seitencodemodell.

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>AdRotator Constructor Example</title>
<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 = @"~\App_Data\Ads.xml";

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

   </script>

</head>

<body>

   <form id="form1" runat="server">

      <h3>AdRotator Constructor Example</h3>

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

   </form>

</body>
</html>

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>AdRotator Constructor Example</title>
<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 = "~\App_Data\Ads.xml"

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

   </script>

</head>

<body>

   <form id="form1" runat="server">

      <h3>AdRotator Constructor Example</h3>

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

   </form>

</body>
</html>

Hinweise

Verwenden Sie diesen Konstruktor, um eine neue Instanz der AdRotator Klasse zu erstellen und zu initialisieren.

Gilt für

Siehe auch