AdRotator Control

The AdRotator control is an ASP.NET rich control that is used to create and manipulate banner advertisements in Web pages. It can automatically rotate through a series of advertisements, displaying each with the specified frequency. The properties of the banner advertisements to be displayed by the control are specified in an XML file.

The properties, methods, and events of the AdRotator control are shown in table:

Property Description
AdvertisementFile The path to the XML file that contains the banner advertisements to be displayed.
KeywordFilter Only the advertisements matching the set filter are returned.
Target When the user clicks the advertisement, the page is opened in this window or frame.possible values are _top, _new, _child, _self, _parent, _blank.
Methods Description
OnAdCreated Raises the AdCreated event.
Events Description
AdCreated Raised after an advertisement is retrieved from the file and before it is rendered.

The format of the XML advertisement file is described below.

        <ImageUrl>URL of Image to Display</ImageUrl>
        <NavigateUrl>URL of Page to Link to</NavigateUrl>
        <AlternateText>Text to show as ToolTip</AlternateText>
        <Keyword>Keyword used to Filter</Keyword>
        <Impressions>Relative weight of ad</Impressions>

The properties of an advertisement are described below. All except the ImageUrl are optional.

  • ImageUrl: It indicates the URL of the image to be displayed in the advertisement. It can be either a relative or an absolute path.
  • NavigateUrl: It indicates the URL of the target Web site to which users will be taken when they click on the advertisement.
  • AlternateText: It is displayed in browsers that do not support images. It is also used to display ToolTip text.
  • Keyword: It indicates the advertisement category.
  • Impressions: It indicates the weightage given to the advertisement with respect to the other advertisements in the file. An advertisement with a higher value will be shown more number of times.

Example 1: Advertisement.xml

        <AlternateText>Go To Rediff.Com</AlternateText>
        <AlternateText>Go To Microsoft.Com</AlternateText>


        <title>AdRotator Control</title> 
    <form runat="server">
        <asp:AdRotator id="ar1" Target="_self" AdvertisementFile="advertisement.xml" BorderWidth="1" runat="server"/>