articles

AdRotator Control in ASP.Net

AdRotator Control in ASP.Net

Pushpendra Singh 10550 22-Oct-2010

The AdRotator is a special control in ASP.NET that is used to display flashing banner ads The control is capable of displaying ads randomly or sequentially as set by the user.

Each time the page is refreshed or reloaded a new ad can be displayed to the user. Also, we can assign priorities in such a way that certain ads are displayed frequently than others. 

<asp:AdRotator ID="AdRotator2" runat="server" />
<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
 
  <Ad>
    <ImageUrl>image_5.png</ImageUrl>
    <NavigateUrl>home.aspx</NavigateUrl>
    <Impressions>1</Impressions>   
  </Ad>
 
  <Ad>
    <ImageUrl>asp_net-design-logo.jpg</ImageUrl>
    <NavigateUrl>home.aspx</NavigateUrl>
    <Impressions>2</Impressions>   
  </Ad>
 
</Advertisements> 

<Impressions>: (Optional) The display rates in percent of the hits. The larger the number, the more often the ad is displayed.

<asp:AdRotator ID="AdRotator1" runat="server" DataSourceID="XmlDataSource1" OnAdCreated="AdRotator1_AdCreated" />
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/XMLFile2.xml">
</asp:XmlDataSource>

The AdCreated event is raised on the server after the AdRotator control is created, but before the page is rendered.

If the AdvertisementFile property is set, the AdCreated event is raised after an advertisement has been selected by theAdRotator control.

How to bind XML file in AdRotator

AdRotator Control in ASP.Net

Click new Data Source

AdRotator Control in ASP.Net

Select XML file and click ok.

AdRotator Control in ASP.Net

Browse and select XML file and click ok.

AdRotator Control in ASP.Net

Run The Project

AdRotator Control in ASP.Net

When Page will refresh the next image will be displayed

AdRotator Control in ASP.Net

When you click on the image then it will be redirected to the specified page.

AdRotator Control in ASP.Net


Updated 04-Mar-2020

Leave Comment

Comments

Liked By