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 attributes define the location where the ASP AdRotator would run/execute.
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.)
The advertisement file contains images for the website, which AdRotator randomly selects.
The syntax for an advertisement file is shown below.
<Advertisements> <Ad> <ImageUrl>Image_01.jpg</ImageUrl> <NavigateUrl>http://www.w3.org/2000/svg</NavigateUrl> <AlternateText>Advertisement 01</AlternateText> <Impressions>60</Impressions> <Keyword>Educative</Keyword> <Category>Script</Category> </Ad> <Ad> <ImageUrl>Image_02.jpg</ImageUrl> <NavigateUrl>http://www.w3.org/2000/svg</NavigateUrl> <AlternateText>Advertisement 02</AlternateText> <Impressions>100</Impressions> <Keyword>Logo</Keyword> <Category>Script</Category> </Ad> </Advertisements>
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.
View all Courses