---
title: "AdRotator in ASP.NET"  
description: "In this blog, I’m explaining about AdRotator in ASP.Net  The AdRotator control presents ad images that, when clicked, navigate to a new web location."  
author: "priyanka kushwaha"  
published: 2015-02-18  
updated: 2015-02-18  
canonical: https://www.mindstick.com/blog/770/adrotator-in-asp-dot-net  
category: ".net"  
tags: ["c#", "asp.net"]  
reading_time: 2 minutes  

---

# AdRotator in ASP.NET

In this blog, I’m explaining about AdRotator in [ASP.Net](https://www.mindstick.com/articles/934/default-folders-available-inside-the-asp-dot-net-application-folder)\

The [AdRotator control](https://www.mindstick.com/interview/2230/explain-the-adrotator-control) presents ad images that, when clicked, navigate to a new web [location](https://www.mindstick.com/blog/11636/relocating-business-or-office-to-another-location). Each time the page is loaded into the [browser](https://www.mindstick.com/blog/155254/which-is-the-best-internet-browser), an ad is randomly selected from a predefined list.

[Attributes](https://www.mindstick.com/articles/13105/2-attributes-that-make-your-odoo-ecommerce-theme-productive-and-engaging) Description

ImageURL The URL of the image to display.

NavigateURL The web location to navigate to when the image is clicked.

If NavigateUrl is not set, the image is not clickable.

AlternateText The text to display if the image is unavailable.

[Keyword](https://www.mindstick.com/forum/33572/sql-inner-join-keyword) The category of the ad, which can be used to [filter](https://www.mindstick.com/forum/1176/filter-in-a-xml-file-in-c-sharp) for specific ads.

[Impressions](https://yourviews.mindstick.com/view/87783/why-are-ad-impressions-important-full-guide) This display rates in percent of the hits.

##### NOTE: All attributes are optional.

##### \
1. To create ad list as an XML file.

2.Create an ad element inside the Advertisements element for each ad that you want to include in the ad list and then save the file.

```
<?xml version="1.0" encoding="utf-8" ?><Advertisements>  <Ad>    <ImageUrl>~/images/A.jpg</ImageUrl>    <width>40px </width>    <height>50px</height> <NavigateUrl>http://www.pastelspace.com/image_detail.php?id=1228</NavigateUrl>       <AlternateText>DotNetCurry Home Page</AlternateText>    <Impressions>40</Impressions>    <Keyword>small1</Keyword>  </Ad>  <Ad>    <ImageUrl>~/images/B.jpg</ImageUrl>   <width>40px </width>    <height>50px</height>    <NavigateUrl>http://www.pastelspace.com/image_detail.php?id=1034</NavigateUrl>    <AlternateText>DotNetCurry Home Page</AlternateText>    <Impressions>40</Impressions>    <Keyword>small2</Keyword>  </Ad>  <Ad>    <ImageUrl>~/images/C.jpg</ImageUrl>    <width>40px</width>    <height>50px</height>    <NavigateUrl>http://www.dotnetcurry.com</NavigateUrl>    <AlternateText>DotNetCurry Home Page</AlternateText>    <Impressions>40</Impressions>    <Keyword>small</Keyword>  </Ad></Advertisements> 
```

2. Create a AdRotatorFIle.aspx

(Rotate Ads without Refreshing the page using AdRotator and ASP.NET Ajax)

```
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AdRotator.aspx.cs" Inherits="AdRotatorProject.AdRotator" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"><head runat="server">    <title></title></head><body>    <form id="form1" runat="server">         <div style="width: 100%;">            <asp:ScriptManager ID="ScriptManager1" runat="server" />            <asp:Timer ID="Timer1" Interval="2000" runat="server" />            <asp:UpdatePanel ID="up1" runat="server">                <Triggers>                    <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />                </Triggers>                <ContentTemplate>                    <asp:AdRotator                        ID="AdRotator1"                        AdvertisementFile="~/AdRotator.xml"                        runat="server" Target="_top" Width="500px" />               </ContentTemplate>            </asp:UpdatePanel>        </div>     </form></body></html>
```

##### Output:

![AdRotator in ASP.NET](https://www.mindstick.com/blogs/be7aa243-cab2-48f8-a00e-fae28db7eceb/images/c7d168a2-26cb-42a7-9b5d-5f0f764b90e5.png)![AdRotator in ASP.NET](https://www.mindstick.com/blogs/be7aa243-cab2-48f8-a00e-fae28db7eceb/images/5536f219-64b6-410d-9d99-89ffea0f0f5d.png)

---

Original Source: https://www.mindstick.com/blog/770/adrotator-in-asp-dot-net

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
