次の方法で共有


AdRotator クラス

Web ページに広告バナーを表示します。

名前空間: System.Web.UI.WebControls
アセンブリ: System.Web (system.web.dll 内)

構文

'宣言
Public Class AdRotator
    Inherits DataBoundControl
'使用
Dim instance As AdRotator
public class AdRotator : DataBoundControl
public ref class AdRotator : public DataBoundControl
public class AdRotator extends DataBoundControl
public class AdRotator extends DataBoundControl
適用できません。

解説

AdRotator コントロールを使用して、選択した広告バナーを Web ページにランダムに表示します。表示される広告は、ページを更新するたびに変更されます。

広告情報は各 XML ファイルに格納されます。XML ファイルは、広告および広告に関連付けられている属性の一覧を維持します。属性には、表示するイメージのパス、コントロールがクリックされたときのリンク先 URL、イメージが使用できないときに表示される代替テキスト、キーワード、および広告の表示時間が含まれます。このファイルの中の情報は AdRotator コントロールで検証されません。広告によって悪意のあるスクリプトが実行されないようにするには、リリース前にデータを必ず検証するか、信頼されているソースからの広告情報だけを受け入れるようにする必要があります。

未承認のインターネット アクセスから広告ファイルを保護するには、次の 1 つ以上の操作を行います。

  • 広告ファイルを App_Data ディレクトリに格納します。このディレクトリは、任意の種類のファイルについてインターネット アクセスを拒否するために設定されています。

  • .xml 以外の拡張子でファイルの名前を変更し、その拡張子を Web.config の HttpForbiddenHandler に割り当てます。詳細については、Machine.config ファイルの httpHandlers 要素 (ASP.NET 設定スキーマ) のセクションを参照してください。

XML ファイルに対するデータの代替ソースとして、コールバック イベントを通じて広告情報を提供できます。このイベントを XML ファイルと組み合わせて使用することで、他のページへのリダイレクトなどの AdRotator コントロールの動作を拡張することもできます。ファイル形式の詳細については、AdvertisementFile プロパティのトピックを参照してください。

それぞれの広告には Impressions 属性を割り当てることができます。この属性は、広告ファイル内の他の広告に対し各広告が選択される頻度を制御します。

メモメモ :

ページ キャッシュが有効な場合、AdRotator コントロールはキャッシュされません。Web ページが更新されるたびに、新しい広告が選択されます。ただし、AdCreated イベントのイベント ハンドラが提供されている場合は、新しい広告は選択されません。

トピック 場所
チュートリアル : AdRotator コントロールを使用した広告の表示と追跡 Visual Studio での ASP .NET Web アプリケーションの作成
方法 : AdRotator Web サーバー コントロールを使用して XML ファイルから広告を表示する Visual Studio ASP .NET での Web アプリケーションの作成
方法 : AdRotator Web サーバー コントロールを使用してデータベースから広告を表示する Visual Studio ASP .NET での Web アプリケーションの作成
チュートリアル : AdRotator コントロールを使用した広告の表示と追跡 Visual Studio ASP .NET での Web アプリケーションの作成
方法 : AdRotator Web サーバー コントロールでプログラムによって広告を選択する Visual Studio ASP .NET での Web アプリケーションの作成
方法 : AdRotator Web サーバー コントロールを使用して XML ファイルから広告を表示する Visual Studio ASP .NET での Web アプリケーションの作成
方法 : AdRotator Web サーバー コントロールを使用してデータベースから広告を表示する Visual Studio ASP .NET での Web アプリケーションの作成
チュートリアル : AdRotator コントロールを使用した広告の表示と追跡 Visual Studio ASP .NET での Web アプリケーションの作成
方法 : AdRotator Web サーバー コントロールでプログラムによって広告を選択する Visual Studio ASP .NET での Web アプリケーションの作成
方法 : AdRotator Web サーバー コントロールを使用して XML ファイルから広告を表示する ASP .NET Web アプリケーションの作成
方法 : AdRotator Web サーバー コントロールを使用してデータベースから広告を表示する ASP .NET Web アプリケーションの作成
方法 : AdRotator Web サーバー コントロールでプログラムによって広告を選択する ASP .NET Web アプリケーションの作成

使用例

AdRotator コントロールを使用して、Web ページに広告バナーを表示する方法のコード例を次に示します。

<%@ 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 Example</title>
</head>
 
 <body>
    <form id="form1" runat="server">
 
       <h3>AdRotator Example</h3>
 
       <asp:AdRotator id="AdRotator1" runat="server"
            Target="_self"
            AdvertisementFile="~/App_Data/Ads.xml"/>
 
    </form>
 </body>
 
 </html>
<%@ 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 Example</title>
</head>
 
 <body>
    <form id="form1" runat="server">
 
       <h3>AdRotator Example</h3>
 
       <asp:AdRotator id="AdRotator1" runat="server"
            Target="_self"
            AdvertisementFile="~/App_Data/Ads.xml"/>
 
    </form>
 </body>
 
 </html>
<%@ Page Language="JScript" 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 Example</title>
</head>
 
 <body>
    <form id="form1" runat="server">
 
       <h3>AdRotator Example</h3>
 
       <asp:AdRotator id="AdRotator1" runat="server"
            Target="_self"
            AdvertisementFile="~/App_Data/Ads.xml"/>
 
    </form>
 </body>
 
 </html>

前の例について、広告情報を含む XML ファイルのファイル形式のコード例を次に示します。ファイル形式の詳細については、AdvertisementFile メンバのトピックを参照してください。

<Advertisements>
  <Ad>
    <ImageUrl>~/Images/image1.jpg</ImageUrl>
    <height>60</height>
    <width>190</width>
    <href>https://www.microsoft.com</href>
    <AlternateText>Microsoft Main Site</AlternateText>
    <Impressions>80</Impressions>
    <Keyword>Topic1</Keyword>
  </Ad>
  <Ad>
    <ImageUrl>~/Images/image2.jpg</ImageUrl>
    <height>90</height>
    <width>90</width>
    <href>http://www.wingtiptoys.com</href>
    <AlternateText>Wingtip Toys</AlternateText>
    <Impressions>80</Impressions>
    <Keyword>Topic2</Keyword>
  </Ad>
</Advertisements>

.NET Framework のセキュリティ

  • AspNetHostingPermission  (ホスト環境での動作に必要なアクセス許可)要求値 : LinkDemand。アクセス許可値 : Minimal
  • AspNetHostingPermission  (ホスト環境での動作に必要なアクセス許可)要求値 : InheritanceDemand。アクセス許可値 : Minimal

継承階層

System.Object
   System.Web.UI.Control
     System.Web.UI.WebControls.WebControl
       System.Web.UI.WebControls.BaseDataBoundControl
         System.Web.UI.WebControls.DataBoundControl
          System.Web.UI.WebControls.AdRotator

スレッド セーフ

この型の public static (Visual Basicでは共有) メンバはすべて,スレッド セーフです。インスタンス メンバの場合は,スレッド セーフであるとは限りません。

プラットフォーム

Windows 98,Windows Server 2000 SP4,Windows CE,Windows Millennium Edition,Windows Mobile for Pocket PC,Windows Mobile for Smartphone,Windows Server 2003,Windows XP Media Center Edition,Windows XP Professional x64 Edition,Windows XP SP2,Windows XP Starter Edition

Microsoft .NET Framework 3.0 は Windows Vista,Microsoft Windows XP SP2,および Windows Server 2003 SP1 でサポートされています。

バージョン情報

.NET Framework

サポート対象 : 3.0,2.0,1.1,1.0

参照

関連項目

AdRotator メンバ
System.Web.UI.WebControls 名前空間
AdCreatedEventArgs
AdCreatedEventHandler デリゲート
AdvertisementFile

その他の技術情報

AdRotator Web サーバー コントロール