AdRotator Example in ASP.NET using C#

AdRotator Example in ASP.NET using C#


Posted in : ASP.Net Posted on : November 20, 2010 at 6:00 PM Comments : [ 0 ]

In this article we will introduce with the AdRotator control in ASP.NET using C#.

AdRotator Example in ASP.NET using C#

AdRotator is a Rich Web Control in ASP.NET. AdRotator control is used to
make rotating advertisement in ASP.NET.It displays the different different
images in web page when you refresh the web page. You can provide the information
about the images which is displayed in AdRotator using XML file or database.
When we click on the images it will redirect on NavigateUrl.

The following are the properties of AdRotator control.

1. AdvertisementFile: The path of the XML file in which you store the information of images.
2. AlternateTextField: A data field to use instead of the Alt text for an advertisement.
3. ImageUrlField: The name of the image url field in which image path is store.
4. NavigateUrlField: The name of the navigate url field in which navigate url is store.
5. Target: The target property specify frame that display the content of the AdRotator. It has four type
_blank, _parent, _self, _top.

The XML file (AdXML.xml) is as:

<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
<Ad>
<ImageUrl>~/Images/image1.gif</ImageUrl>
<NavigateUrl>http://roseindia.net</NavigateUrl>
<AlternateText>Roseindia</AlternateText>
<Keyword>Site1</Keyword>
</Ad>
<Ad>
<ImageUrl>~/Images/image2.png</ImageUrl>
<NavigateUrl>http://www.google.com</NavigateUrl>
<AlternateText>Google</AlternateText>
<Keyword>Site2</Keyword>
</Ad>
</Advertisements>

AdRotator.aspx (Design page):

AdRotator.aspx (source page):

<%@ Page Language="C#" AutoEventWireup="true" 
MasterPageFile="~/RoseindiaMaster.master" 
CodeFile="AdRotator.aspx.cs" Inherits="AdRotator" %>
<asp:Content ID="Content1" runat="server" 
contentplaceholderid="ContentPlaceHolder1">
<div>
<h2 style="color:Green">AdRotator in ASP.NET 4, C#</h2>
<asp:AdRotator ID="AdRotator1" 
runat="server" 
Width="468px" 
Height="60px" 
AdvertisementFile="~/XML/Adxml.xml"/>
</div>
</asp:Content>

Output:

View the page in browser is as follows:

When you refresh the page the second image will be display as follows:

 

Download source code
Go to Topic «PreviousHomeNext»

Your Comment:


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

 
Tutorial Topics