AdCreatedEventArgs.AdProperties プロパティ

定義

現在表示されている広告のすべての広告プロパティが格納されている IDictionary オブジェクトを取得します。

public:
 property System::Collections::IDictionary ^ AdProperties { System::Collections::IDictionary ^ get(); };
public System.Collections.IDictionary AdProperties { get; }
member this.AdProperties : System.Collections.IDictionary
Public ReadOnly Property AdProperties As IDictionary

プロパティ値

現在表示されている広告の広告プロパティのリストが格納されている IDictionary。 既定値は Empty です。

次のコード例では、イベント ハンドラーで OnAdCreated プロパティをAdProperties使用してカスタム キャプションを提供する方法を示します。

<%@ 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>
 
    <script language="c#" runat="server">
       void AdCreated_Event(Object sender, AdCreatedEventArgs e) 
       {
          Message.Text=(string)e.AdProperties["Caption"];
       }      
    </script>
 
 <body>
 
    <form id="form1" runat="server">
 
       <h3>AdRotator Example</h3>
 
       <asp:AdRotator id="test1" runat="server"
            AdvertisementFile = "Ads.xml"
        Borderwidth="1"
            Target="_newwwindow"
            OnAdCreated="AdCreated_Event"/><br /><br />
 
       <asp:label id="Message" 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 Example</title>
</head>
 
    <script language="vb" runat="server">
       Sub AdCreated_Event(sender As Object, e As AdCreatedEventArgs) 
          Message.Text = e.AdProperties("Caption")
       End Sub     
    </script>
 
 <body>
 
    <form id="form1" runat="server">
 
       <h3>AdRotator Example</h3>
 
       <asp:AdRotator id="test1" runat="server"
            AdvertisementFile = "Ads.xml"
        Borderwidth="1"
            Target="_newwwindow"
            OnAdCreated="AdCreated_Event"/><br /><br />
 
       <asp:label id="Message" runat="server"/>
 
    </form>
 
 </body>
 </html>

<Advertisements>
 
     <Ad>
         <ImageUrl>image1.jpg</ImageUrl>
         <NavigateUrl>http://www.microsoft.com</NavigateUrl>
         <AlternateText>Microsoft Main Site</AlternateText>
         <Impressions>80</Impressions>
         <Keyword>Topic1</Keyword>
         <Caption>This is the caption for Ad#1</Caption>          
     </Ad>
 
     <Ad>
         <ImageUrl>image2.jpg</ImageUrl>
         <NavigateUrl>http://www.wingtiptoys.com</NavigateUrl>
         <AlternateText>Wing Tip Toys</AlternateText>
         <Impressions>80</Impressions>
         <Keyword>Topic2</Keyword>
         <Caption>This is the caption for Ad#2</Caption>                
     </Ad>
 
 </Advertisements>

次のコード例では、アドバタイズ XML ファイルにアドバタイズに関するカスタム属性を含める方法を示します。 XML ファイルの詳細については、 クラスの プロパティをAdvertisementFileAdRotator参照してください。

<Advertisements>  
 <Ad>  
 <ImageUrl>image1.jpg</ImageUrl>  
 <NavigateUrl>http://www.microsoft.com</NavigateUrl>  
 <AlternateText>Microsoft Main Site</AlternateText>  
 <Impressions>80</Impressions>  
 <Keyword>Topic1</Keyword>  
 <Caption>This is the caption for Ad#1</Caption>   
 </Ad>  
 <Ad>  
 <ImageUrl>image2.jpg</ImageUrl>  
 <NavigateUrl>http://www.wingtiptoys.com</NavigateUrl>  
 <AlternateText>Wingtip Toys</AlternateText>  
 <Impressions>80</Impressions>  
 <Keyword>Topic2</Keyword>  
 <Caption>This is the caption for Ad#2</Caption>   
 </Ad>  
</Advertisements>  

注釈

プロパティを AdProperties 使用して、 System.Collections.IDictionary 現在表示されているアドバタイズのアドバタイズプロパティを含むオブジェクトを取得します。 オブジェクトの System.Collections.IDictionary キーと値は 型 System.Stringです。

コントロールは AdRotator 、Web ページにコントロールが表示されるたびに、広告をランダムに選択します。 選択したアドバタイズメントの属性は、アドバタイズ XML ファイルから抽出され、オブジェクトに System.Collections.IDictionary 格納されます。 コントロールが クラスの AdRotator 新しいインスタンスを AdCreatedEventArgs 作成すると、 AdProperties プロパティは オブジェクトで System.Collections.IDictionary 初期化されます。

アドバタイズに関するカスタム属性 (アドバタイズキャプションなど) をアドバタイズ XML ファイルに含めることもできます。 イベント ハンドラーでこのプロパティを OnAdCreated 使用して、カスタム属性を取得します。

適用対象

こちらもご覧ください