Home   |   QuickStart Welcome   |   ASP.NET   |   Web Services   |   How Do I...?   
  |   I want my samples in...      

ASP.NET 2.0 Quickstart Tutorials

AdRotator

The AdRotator control presents ad images that, when clicked, navigate to a new Web location. Each time the page is loaded into the browser, an ad is randomly selected from a predefined list. The following sample illustrates using the AdRotator control.

VB AdRotator1.aspx
Run Sample View Source

The rotation schedule for ads is defined in an XML file. The following example demonstrates a rotation schedule in the file ads.xml.
<Advertisements>
   <Ad>
      <ImageUrl>images/banner1.gif</ImageUrl>
      <NavigateUrl>http://www.microsoft.com</NavigateUrl>
      <AlternateText>Microsoft.com</AlternateText>
      <Keyword>Computers</Keyword>
      <Impressions>80</Impressions>
   </Ad>
</Advertisements>
The rotation file defines the following attributes of each ad. Except for ImageUrl, these attributes are optional.

Attribute Description
ImageUrl An absolute or relative URL to the ad image file.
NavigateUrl The Web location to navigate to when the image is clicked. If NavigateUrl is not set, the image is not clickable.
AlternateText The text to render as the ALT attribute of the image. When the page is viewed with Microsoft Internet Explorer, this acts as a ToolTip for the ad.
Keyword Specifies a category for the ad that the page can filter on.
Impressions A number that indicates the "weight" of the ad in the schedule of rotation relative to the other ads in the file. The larger the number, the more often the ad will be displayed.

See Also:   AdRotator Object Model