Thursday, October 7, 2010

ASP AdRotator Server Control

This control is used to display collection of advertisements simultaneously, this control automatically rotating advertisements when web page is refreshing, AdRotator control the Microsoft designed based on extensible markup language (XML). So we use XML data to this AdRotator Control.

Right click on your solution file and select add New Item, there you select XML file then press OK.

In xml file add the below code.
<Advertisements>
<Ad>
<ImageUrl>~/Images/CoolTuts.JPG</ImageUrl>
<NavigateUrl>http://www.cooltuts.com/</NavigateUrl>
</Ad>
<Ad>
<ImageUrl>~/Images/PleaseWait.JPG</ImageUrl>
<NavigateUrl>http://www.desibindaas.com/</NavigateUrl>
</Ad>
<Ad>
<ImageUrl>~/Images/Submit.JPG</ImageUrl>
<NavigateUrl>http://www.bing.com/</NavigateUrl>
</Ad>
</Advertisements>

The elements we use mainly in this XML file is explained below.

ImageUrl: Location of your Image.
NavigationUrl: Where to navigate when the image is clicked.
AlternateText: This is useful when there is now image in your file.
Impressions: this indicates the likelihood of the image getting selected for display.
Keyword: this sets the category of the image in order to allow for the filtering of ads.

After adding a XML file to your project with adding above code in it. Its time to add AdRotator to your page with having a property AdvertisementFile=”XML File” as shown below.

<asp:AdRotator ID="AdRotator1" runat="server"
AdvertisementFile="~/XMLFile.xml" />

Hence you see by refreshing the web page. The Ads are changing according to your impression element timings.

Thanks
Emmaneale Mendu
Web Developer.

No comments:

Post a Comment