Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags


How to use AdRotator in ASP

Dian Us Suqlain

Application Server Pages - (ASP) is developed by Microsoft as a web application framework for programmers to create dynamic websites and software.

AdRotator is a component of ASP that displays ads in webpages and randomly selects graphic banners from a list present in an external XML file (known as the advertisement file).

Every time the user visits the page or refreshes it, a different image gets loaded from the XML file and is displayed on the webpage.



In ASP, we can add AdRotator to control the flow of ads. The syntax is shown below.

<asp:AdRotator runat = "server" AdvertisementFile = "adfile.xml" Target = "_blank" />

The tag above includes attributes such as runat, AdvertisementFile, and Target.

The runat attributes define the location where the ASP AdRotator would run/execute.

The AdvertisementFile file attributes specify the XML file that includes images and pictures.

We use the Target attribute to define how the page would open (such as in a new tab, same tab, blank tab, etc.)

How images are loaded in ASP website through AdRotator

Advertisement xml file


The advertisement file contains images for the website, which AdRotator randomly selects.

The syntax for an advertisement file is shown below.

    <AlternateText>Advertisement 01</AlternateText>  

    <AlternateText>Advertisement 02</AlternateText>  

Advertisement XML file (AdRotator)


The syntax above includes some tags that have a specified usage, such as:

  • <Advertisements>: This is the root node of the XML file that includes multiple Ad tags.

  • <Ad>: Each Ad tag in an XML file includes attributes such as ImageURL, NavigateUrl, AlternateText, Impressions, Keyword, and Category.

  • <ImageUrl>: This tag includes the image URL or path to import it into the website.

  • <NavigateUrl>: This tag includes a link that opens if the user clicks the banner.

  • <AlternateText>: If the image is unavailable, the text inside this tag will get displayed.

  • <Keyword>: This tag identifies a group of advertisements.

  • <Category>: We use this tag when multiple categories are in an XML file.




Dian Us Suqlain
Copyright ©2022 Educative, Inc. All rights reserved

View all Courses

Keep Exploring