AdCreatedEventArgs Class
Assembly: System.Web (in system.web.dll)
The AdCreated event is raised when the AdRotator control displays an advertisement on the page.
For a list of initial property values for an instance of AdCreatedEventArgs, see the AdCreatedEventArgs constructor.
For more information about handling events, see Events and Delegates.
| Topic | Location |
|---|---|
| How to: Select Ads in an AdRotator Web Server Control Programmatically | Building ASP .NET Web Applications |
| How to: Select Ads in an AdRotator Web Server Control Programmatically | Building ASP .NET Web Applications |
The following code example demonstrates how to specify and code a handler for the AdCreated event. It gets the URL associated with the advertisement when the AdRotator control gets created and displays it below the control. This example requires the XML file (Ads.xml) listed in the example below.
<%@ 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.NavigateUrl End Sub </script> <body> <form runat="server"> <h3>AdRotator Example</h3> <asp:AdRotator id="test1" runat="server" AdvertisementFile = "~/App_Data/Ads.xml" Borderwidth="1" Target="_blank" OnAdCreated="AdCreated_Event"/><br><br> <asp:label id="Message" runat="server"/> </form> </body> </html>
The following code example demonstrates how to format the XML file that contains the advertisement information. 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>
<%@ Page Language="VB" AutoEventWireup="True" %> <html> <head> </head> <script runat="server"> Sub Page_Load(sender As Object, e As EventArgs) ' Create an EventHandler delegate for the method you want to handle the event ' and then add it to the list of methods called when the event is raised. AddHandler Ad.AdCreated, AddressOf AdCreated_Event End Sub Sub AdCreated_Event(sender As Object, e As AdCreatedEventArgs) ' Override the AlternateText value from the ads.xml file. e.AlternateText = "Visit this site!" End Sub </script> <body> <form runat="server"> <h3>AdRotator AdCreated Example</h3> Notice that the AlternateText property of the advertisement <br> has been programmatically modified from the value in the XML <br> file. <br><br> <asp:AdRotator id="Ad" runat="server" AdvertisementFile = "~/App_Data/Ads.xml" Borderwidth="1" Target="_blank"/> </form> </body> </html>
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.