AdRotator Oluşturucu

Tanım

AdRotator sınıfının yeni bir örneğini başlatır.

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

Örnekler

Aşağıdaki kod örneğinde sınıfının yeni bir örneğinin nasıl oluşturulacağı ve başlatacağı gösterilmektedir AdRotator . Daha sonra yeni AdRotator denetim bir PlaceHolder denetim koleksiyonuna Control.Controls eklenir ve Web Forms sayfasında görüntülenir.

Not

Aşağıdaki kod örneği tek dosyalı kod modelini kullanır ve doğrudan arka planda kod dosyasına kopyalandığında düzgün çalışmayabilir. Bu kod örneği, .aspx uzantısına sahip boş bir metin dosyasına kopyalanmalıdır. Web Forms kod modeli hakkında daha fazla bilgi için bkz. Sayfa Kodu Modeli ASP.NET Web Forms.

<%@ 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>

Açıklamalar

Sınıfının yeni bir örneğini oluşturmak ve başlatmak için bu oluşturucuyu AdRotator kullanın.

Şunlara uygulanır

Ayrıca bkz.