AdRotator コンストラクター

定義

AdRotator クラスの新しいインスタンスを初期化します。

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

次のコード例は、クラスの新しいインスタンスを作成および初期化する方法を AdRotator 示しています。 その後、新しいAdRotatorコントロールがコントロールのPlaceHolderコレクションにControl.Controls追加され、Web Forms ページに表示されます。

注意

次のコード サンプルでは、シングル ファイル コード モデルを使用します。分離コード ファイルに直接コピーした場合、正しく動作しない場合があります。 このコード サンプルは、拡張子が .aspx の空のテキスト ファイルにコピーする必要があります。 Web Forms コード モデルの詳細については、「ページ コード モデルの 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>

注釈

このコンストラクターを使用して、クラスの AdRotator 新しいインスタンスを作成および初期化します。

適用対象

こちらもご覧ください