This documentation is archived and is not being maintained.

AdCreatedEventArgs.AdProperties Property

Gets a System.Collections.IDictionary object that contains all the advertisement properties for the currently displayed advertisement.

[Visual Basic]
Public ReadOnly Property AdProperties As IDictionary
[C#]
public IDictionary AdProperties {get;}
[C++]
public: __property IDictionary* get_AdProperties();
[JScript]
public function get AdProperties() : IDictionary;

Property Value

A System.Collections.IDictionary object that contains a list of advertisement properties for the currently displayed advertisement. The default value is String.Empty.

Remarks

Use the AdProperties property to get a System.Collections.IDictionary object that contains the advertisement properties for the currently displayed advertisement. The keys and values of the System.Collections.IDictionary object are of type System.String.

The AdRotator control randomly selects an advertisement each time the control is displayed on the Web page. The attributes for the selected advertisement are extracted from the advertisement XML file and stored in a System.Collections.IDictionary object. When the AdRotator control creates a new instance of the AdCreatedEventArgs class, the AdProperties property gets initialized with the System.Collections.IDictionary object.

Custom attributes about an advertisement, such as an advertisement caption, may also be included in the advertisement XML file. Use this property in the OnAdCreated event handler to get the custom attributes.

Example

[Visual Basic, C#, JScript] The following example demonstrates how to use the AdProperties in the OnAdCreated event handler to provide a custom caption.

[Visual Basic] 
<%@ Page Language="VB" AutoEventWireup="True" %>

<html>
 <head>
 
 </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 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>


[C#] 
<%@ Page Language="C#" AutoEventWireup="True" %>

<html>
 <head>
 
 </head>
 
    <script language="C#" runat="server">
       void AdCreated_Event(Object sender, AdCreatedEventArgs e) 
       {
          Message.Text=(string)e.AdProperties["Caption"];
       }      
    </script>
 
 <body>
 
    <form 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>


[JScript] 
<%@ Page Language="JScript" AutoEventWireup="True" %>

<html>
 <head>
 
 </head>
 
    <script language="JScript" runat="server">
       function AdCreated_Event(sender, e : AdCreatedEventArgs) 
       {
          Message.Text=String(e.AdProperties["Caption"]);
       }      
    </script>
 
 <body>
 
    <form 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>

[Visual Basic, C#, JScript] The following example demonstrates how to include custom attributes about an advertisement in the advertisement XML file. For additional 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>Wing Tip Toys</AlternateText>
 <Impressions>80</Impressions>
 <Keyword>Topic2</Keyword>
 <Caption>This is the caption for Ad#2</Caption> 
 </Ad>
 
</Advertisements>

[C++] No example is available for C++. To view a Visual Basic, C#, or JScript example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

AdCreatedEventArgs Class | AdCreatedEventArgs Members | System.Web.UI.WebControls Namespace | AdRotator.AdvertisementFile | OnAdCreated | System.Collections.IDictionary | String.Empty

Show: