Preferred Language:
Listing 4.11 - AdRotatorXML.aspx
Illustrates how to use teh ASP.NET AdRotator control.
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<style type="text/css">
html
{
background-color:silver;
}
.content
{
background-color:white;
padding:10px;
border:solid 1px black;
margin:auto;
width:400px;
text-align:center;
}
.box
{
float:right;
padding:10px;
border-left:solid 1px black;
}
.clear
{
clear:both;
}
</style>
<title>AdRotator XML</title>
</head>
<body>
<form id="form1" runat="server">
<div class="content">
<asp:AdRotator
id="AdRotator1"
AdvertisementFile="App_Data/AdList.xml"
KeywordFilter="banner"
CssClass="banner"
Runat="server" />
<br />
<div class="box">
<asp:AdRotator
id="AdRotator2"
AdvertisementFile="App_Data/AdList.xml"
KeywordFilter="box"
Runat="server" />
<br /><br />
<asp:AdRotator
id="AdRotator3"
AdvertisementFile="App_Data/AdList.xml"
KeywordFilter="box"
Runat="server" />
</div>
<br />Here is the body text in the page.
<br />Here is the body text in the page.
<br />Here is the body text in the page.
<br />Here is the body text in the page.
<br class="clear" />
</div>
</form>
</body>
</html>
The AdRotator control in the page above uses the XML file below.
<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
<!-- Banner Advertisements -->
<Ad>
<ImageUrl>~/Ads/BannerAd1.gif</ImageUrl>
<Width>300</Width>
<Height>50</Height>
<NavigateUrl>http://www.AspWorkshops.com</NavigateUrl>
<AlternateText>Banner Advertisement 1</AlternateText>
<Impressions>50</Impressions>
<Keyword>banner</Keyword>
</Ad>
<Ad>
<ImageUrl>~/Ads/BannerAd2.gif</ImageUrl>
<Width>300</Width>
<Height>50</Height>
<NavigateUrl>http://www.AspWorkshops.com</NavigateUrl>
<AlternateText>Banner Advertisement 2</AlternateText>
<Impressions>25</Impressions>
<Keyword>banner</Keyword>
</Ad>
<Ad>
<ImageUrl>~/Ads/BannerAd3.gif</ImageUrl>
<Width>300</Width>
<Height>50</Height>
<NavigateUrl>http://www.AspWorkshops.com</NavigateUrl>
<AlternateText>Banner Advertisement 3</AlternateText>
<Impressions>25</Impressions>
<Keyword>banner</Keyword>
</Ad>
<!-- Box Advertisements -->
<Ad>
<ImageUrl>~/Ads/BoxAd1.gif</ImageUrl>
<Width>150</Width>
<Height>150</Height>
<NavigateUrl>http://www.AspWorkshops.com</NavigateUrl>
<AlternateText>Box Advertisement 1</AlternateText>
<Impressions>50</Impressions>
<Keyword>box</Keyword>
</Ad>
<Ad>
<ImageUrl>~/Ads/BoxAd2.gif</ImageUrl>
<Width>150</Width>
<Height>150</Height>
<NavigateUrl>http://www.AspWorkshops.com</NavigateUrl>
<AlternateText>Box Advertisement 2</AlternateText>
<Impressions>50</Impressions>
<Keyword>box</Keyword>
</Ad>
</Advertisements>
ASP.NET 3.5 Unleashed
- Containing almost 2,000 pages of code samples and in-depth explanation of the
ASP.NET 3.5 Framework, ASP.NET 3.5 Unleashed is the most comprehensive book
written on the ASP.NET 3.5 Framework.
ASP.NET 3.5 Unleashed is now available in your local bookstore and online (Published January 7, 2008).
All of the code samples from this book are hosted "live" at this website.
Click here
to view the table of contents and code samples.