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입니다.

예제

다음 코드 예제에 사용 하는 방법을 보여 줍니다.는 AdProperties 속성에는 OnAdCreated 이벤트 처리기를 사용자 지정 캡션을 제공 합니다.

<%@ 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 파일에 대 한 자세한 내용은 참조 하세요. 합니다 AdvertisementFile 의 속성을 AdRotator 클래스입니다.

<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 광고 컨트롤이 웹 페이지에 표시 될 때마다 무작위로 선택 합니다. 선택된 된 광고에 대 한 특성은 광고 XML 파일에서 추출 하 고 저장을 System.Collections.IDictionary 개체입니다. 경우는 AdRotator 컨트롤의 새 인스턴스를 만듭니다를 AdCreatedEventArgs 클래스는 AdProperties 속성으로 초기화 됩니다는 System.Collections.IDictionary 개체입니다.

또한 XML 광고 파일에서 광고 캡션과 등 광고에 대 한 사용자 지정 특성을 포함할 수 있습니다. 이 속성을 사용 하 여는 OnAdCreated 이벤트 처리기를 사용자 지정 특성을 가져옵니다.

적용 대상

추가 정보