Introduction
The Adrotator control displays a sequence of images, known as advertisements, on a Web page. The sequence in which the images appear can be predefined or random in nature. These advertisements, which all Internet users are familiar with, are image files in GIF, JPEG, or other format that the user can click to navigate to the advertiser's website.
Public Properties of the Adrotator Class
AdvertisementFile : Obtains or sets the path to an XML document that contain advertisement information.
Design a xml file for advertisements name as "advertisements.xml"
The Adrotator control displays a sequence of images, known as advertisements, on a Web page. The sequence in which the images appear can be predefined or random in nature. These advertisements, which all Internet users are familiar with, are image files in GIF, JPEG, or other format that the user can click to navigate to the advertiser's website.
Public Properties of the Adrotator Class
AdvertisementFile : Obtains or sets the path to an XML document that contain advertisement information.
Design a xml file for advertisements name as "advertisements.xml"
<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
<Ad>
<ImageUrl>security.JPG</ImageUrl>
<Width>
200px
</Width>
<Height>
200px
</Height>
</Ad>
<Ad>
<ImageUrl>images.JPG</ImageUrl>
<Width>
100px
</Width>
<Height>
200px
</Height>
</Ad>
</Advertisements>
Drag and drop adrotator control onto the design window from toolbox
<Advertisements>
<Ad>
<ImageUrl>security.JPG</ImageUrl>
<Width>
200px
</Width>
<Height>
200px
</Height>
</Ad>
<Ad>
<ImageUrl>images.JPG</ImageUrl>
<Width>
100px
</Width>
<Height>
200px
</Height>
</Ad>
</Advertisements>
<%@ Page Language="C#" %>
<!DOCTYPE html>
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:AdRotator ID="AdRotator1" runat="server" AdvertisementFile="~/advertisements.xml" />
</div>
</form>
</body>
</html>
Output
<!DOCTYPE html>
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:AdRotator ID="AdRotator1" runat="server" AdvertisementFile="~/advertisements.xml" />
</div>
</form>
</body>
</html>