---
title: "AdRotator Control in ASP.Net"  
description: "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 sequ"  
author: "Pushpendra Singh"  
published: 2010-10-22  
updated: 2020-03-04  
canonical: https://www.mindstick.com/articles/175/adrotator-control-in-asp-dot-net  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 2 minutes  

---

# AdRotator Control in ASP.Net

The [AdRotator](https://www.mindstick.com/blog/650/how-to-use-adrotator-in-asp-dot-net) is a special [control in ASP.NET](https://www.mindstick.com/forum/297/user-control-in-asp-dot-net-mvc) that is used to display flashing [banner ads](https://yourviews.mindstick.com/view/84041/mobile-banner-ads-ultimate-guide-to-success) The control is [capable of displaying ads](https://www.mindstick.com/Articles/525/groupbox-control-in-wpf) 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](https://yourviews.mindstick.com/view/87783/why-are-ad-impressions-important-full-guide)>:** ([Optional](https://www.mindstick.com/interview/22851/main-difference-between-optional-and-required-keywords)) 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](https://www.mindstick.com/articles/198559/an-ownership-of-property-in-hua-hin) is set, the AdCreated event is raised after an advertisement has been [selected by theAdRotator](https://www.mindstick.com/articles/541/datepicker-control-in-wpf) control.

**How to bind [XML file](https://www.mindstick.com/articles/75/how-to-read-and-write-xml-file-through-c-sharp) in AdRotator**

![AdRotator Control in ASP.Net](https://www.mindstick.com/mindstickarticle/8766b284-d4bf-4ae1-891f-03f74d2a50b8/images/da0026be-807d-4ff5-bf01-9ee139489984.png)

Click new [Data Source](https://www.mindstick.com/forum/160659/how-do-you-create-a-custom-filter-to-filter-any-text-in-the-data-source-in-angularjs)

![AdRotator Control in ASP.Net](https://www.mindstick.com/mindstickarticle/8766b284-d4bf-4ae1-891f-03f74d2a50b8/images/f49ff5a2-aacb-4440-85a5-c03df0b145d9.png)

Select XML file and click ok.

![AdRotator Control in ASP.Net](https://www.mindstick.com/mindstickarticle/8766b284-d4bf-4ae1-891f-03f74d2a50b8/images/5f588b23-e7ef-4bb1-a52f-828f6822a687.png)

Browse and select XML file and click ok.

![AdRotator Control in ASP.Net](https://www.mindstick.com/mindstickarticle/8766b284-d4bf-4ae1-891f-03f74d2a50b8/images/ab28e1d9-5adb-4cf0-b524-12d69eb1a915.png)

Run The Project

![AdRotator Control in ASP.Net](https://www.mindstick.com/mindstickarticle/8766b284-d4bf-4ae1-891f-03f74d2a50b8/images/4c8b30cd-cfc7-4c38-9925-244a2e1133d2.png)

When Page will refresh the next image will be displayed

![AdRotator Control in ASP.Net](https://www.mindstick.com/mindstickarticle/8766b284-d4bf-4ae1-891f-03f74d2a50b8/images/2a8018f3-3135-412d-bd27-1ba208e6f24a.png)

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

![AdRotator Control in ASP.Net](https://www.mindstick.com/mindstickarticle/8766b284-d4bf-4ae1-891f-03f74d2a50b8/images/6df4df2a-8c93-47ef-80cf-9e77b50eb7e0.png)

---

Original Source: https://www.mindstick.com/articles/175/adrotator-control-in-asp-dot-net

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
