AdCreatedEventArgs.AdProperties Propriedade

Definição

Obtém um objeto IDictionary que contém todas as propriedades de anúncio para o anúncio exibido no momento.Gets a IDictionary object that contains all the advertisement properties for the currently displayed advertisement.

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

Valor da propriedade

IDictionary

Um IDictionary que contém uma lista de propriedades de anúncio para o anúncio exibido no momento.A IDictionary that contains a list of advertisement properties for the currently displayed advertisement. O valor padrão é Empty.The default value is Empty.

Exemplos

O exemplo de código a seguir demonstra como usar a AdProperties propriedade no OnAdCreated manipulador de eventos para fornecer uma legenda personalizada.The following code example demonstrates how to use the AdProperties property in the OnAdCreated event handler to provide a custom caption.

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

O exemplo de código a seguir demonstra como incluir atributos personalizados sobre um anúncio no arquivo XML do anúncio.The following code example demonstrates how to include custom attributes about an advertisement in the advertisement XML file. Para obter mais informações sobre o arquivo XML, consulte a AdvertisementFile propriedade da AdRotator classe.For more information on the XML file, see the AdvertisementFile property of the AdRotator class.

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

Comentários

Use a AdProperties propriedade para obter um System.Collections.IDictionary objeto que contém as propriedades do anúncio para o anúncio exibido no momento.Use the AdProperties property to get a System.Collections.IDictionary object that contains the advertisement properties for the currently displayed advertisement. As chaves e os valores do System.Collections.IDictionary objeto são do tipo System.String .The keys and values of the System.Collections.IDictionary object are of type System.String.

O AdRotator controle seleciona aleatoriamente um anúncio toda vez que o controle é exibido na página da Web.The AdRotator control randomly selects an advertisement each time the control is displayed on the Web page. Os atributos para o anúncio selecionado são extraídos do arquivo XML de anúncio e armazenados em um System.Collections.IDictionary objeto.The attributes for the selected advertisement are extracted from the advertisement XML file and stored in a System.Collections.IDictionary object. Quando o AdRotator controle cria uma nova instância da AdCreatedEventArgs classe, a AdProperties propriedade é inicializada com o System.Collections.IDictionary objeto.When the AdRotator control creates a new instance of the AdCreatedEventArgs class, the AdProperties property gets initialized with the System.Collections.IDictionary object.

Atributos personalizados sobre um anúncio, como uma legenda de anúncio, também podem ser incluídos no arquivo XML de anúncio.Custom attributes about an advertisement, such as an advertisement caption, can also be included in the advertisement XML file. Use essa propriedade no OnAdCreated manipulador de eventos para obter os atributos personalizados.Use this property in the OnAdCreated event handler to get the custom attributes.

Aplica-se a

Confira também