AdCreatedEventArgs.AdProperties Propriété

Définition

Obtient un objet IDictionary qui contient toutes les propriétés de publication pour la publication affichée.

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

Valeur de propriété

IDictionary qui contient une liste de propriétés de publication pour la publication affichée. La valeur par défaut est Empty.

Exemples

L’exemple de code suivant montre comment utiliser la AdProperties propriété dans le OnAdCreated gestionnaire d’événements pour fournir une légende personnalisée.

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

L’exemple de code suivant montre comment inclure des attributs personnalisés concernant une publicité dans le fichier XML de la publicité. Pour plus d’informations sur le fichier XML, consultez la AdvertisementFile propriété de la AdRotator classe .

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

Remarques

Utilisez la AdProperties propriété pour obtenir un System.Collections.IDictionary objet qui contient les propriétés de la publicité actuellement affichée. Les clés et les valeurs de l’objet System.Collections.IDictionary sont de type System.String.

Le AdRotator contrôle sélectionne aléatoirement une publicité chaque fois que le contrôle s’affiche sur la page Web. Les attributs de la publicité sélectionnée sont extraits du fichier XML de la publicité et stockés dans un System.Collections.IDictionary objet. Lorsque le AdRotator contrôle crée une instance de la AdCreatedEventArgs classe, la AdProperties propriété est initialisée avec l’objet System.Collections.IDictionary .

Les attributs personnalisés relatifs à une publicité, tels qu’une légende de publicité, peuvent également être inclus dans le fichier XML de la publicité. Utilisez cette propriété dans le OnAdCreated gestionnaire d’événements pour obtenir les attributs personnalisés.

S’applique à

Voir aussi