Home > DeveloperSection > Beginner > AdRotator Control in ASP.Net

AdRotator Control in ASP.Net


ASP.Net ASP.Net 
Ratings:
0 Comment(s)
 5317  View(s)
Rate this:

AdRotator Control in ASP.Net

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 the AdRotator control.

How 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 clik ok.

AdRotator Control in ASP.Net

Run The Project

AdRotator Control in ASP.Net

When Page will refresh next image will be displayed

AdRotator Control in ASP.Net

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

AdRotator Control in ASP.Net


Don't want to miss updates? Please click the below button!

Follow MindStick