AdRotator control in ASP.NET using VB.NET

This article shows how to use AdRotator control in ASP. NET.
  • 1794

This article shows how to use AdRotator control in ASP. NET.

AdRotator control

AdRotator control are used to create a dynamic ads.

AdRotator control to work we need an Advertisement file (XML file) and some sample images. 

Working with AdRotator control:

Add a new XML file to the project selecting from Project->Add New Item->XML File from the main menu. Name this XML file as Ads.xml.

The advertisement file is an XML file. The following are some of the elements of this XML file.
 

  1. <imageUrl>: Optional. The path to the image file.
  2. <NavigateUrl>: Optional. The URL to link to if the user clicks the ad.
  3. <AlternateText>: Optional. An alternate text for the image.
  4. <Impressions>: Optional. The display rates in percent of the hits.

The file Ads.xml looks like the code below: 

<Advertisements>

   <Ad>

    <ImageUrl>adimages/2.jpg</ImageUrl>

    <NavigateUrl>http://cat2.com</NavigateUrl>

    <AlternateText>Cat 2</AlternateText>

    <Impressions>30</Impressions>

  </Ad>

  <Ad>

    <ImageUrl>adimages/3.jpg</ImageUrl>

    <NavigateUrl>http://cat3.com</NavigateUrl>

    <AlternateText>Cat 3</AlternateText>

    <Impressions>20</Impressions>

  </Ad>

  <Ad>

    <ImageUrl>adimages/4.jpg</ImageUrl>

    <NavigateUrl>http://cat4.com</NavigateUrl>

    <AlternateText>Cat 4</AlternateText>

    <Impressions>10</Impressions>

  </Ad>

</Advertisements>

 

In the above xml file the 2.jpg, 3.jpg,4.jpg are the image name.

 

Solution explorer looks like this:

 

adrotator 1.gif
 


Figure 1.


 

Drag AdRotator control from toolbox on the form.


 

Now click AdRotator1 and then press the F4 key to view its properties.

Set the AdvertisementFile property to file name myads.xml.


 

adrotator 2.gif
 


Figure 2.
 

Save and build the project.

 

After build the project refresh the page.

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.