HOME

ASP.NET Tutorial
ASP.NET HOME
ASP.NET Intro
ASP.NET vs ASP
ASP.NET Install
ASP.NET Pages
ASP.NET Controls
ASP.NET Events

References
HTML Controls
Web Controls
Validation Controls
Download XMLSpy here
Please visit our sponsors !

AdRotator Control

Back

Definition and Usage

The AdRotator control is used to display a sequence of ad images.

This control uses an XML file to store the ad information. The XML file must begin and end with an <Advertisements> tag. Inside the <Advertisements> tag there may be several <Ad> tags which defines each ad.

The predefined elements inside the <Ad> tag are listed below:

Element Description
<ImageUrl> Optional. The path to the image file
<NavigateUrl> Optional. The URL to link to if the user clicks the ad
<AlternateText> Optional. An alternate text for the image
<Keyword> Optional. A category for the ad
<Impressions> Optional. The display rates in percent of the hits


Properties

Property Description
AdvertisementFile The path to the XML file that contains ad information
id A unique id for the control
KeywordFilter A filter to limit ads after categories
OnAdCreated The name of the function to be executed after the creation of the control, before page rendering
runat Specifies that the control is a server control.  Must be set to "server"
Target Where to open the URL

Example 1

Here is the Ad1.xml file:

<Advertisements>
<Ad>
<ImageUrl>../banners/w6.gif</ImageUrl>
<NavigateUrl>http://www.w3schools.com</NavigateUrl>
<AlternateText>W3Schools Main Site</AlternateText>
<Impressions>50</Impressions>
<Keyword>elearning</Keyword>
</Ad>
<Ad>
<ImageUrl>../banners/setupsite.gif</ImageUrl>
<NavigateUrl>http://www.setupsite.com</NavigateUrl>
<AlternateText>SetupSite Main Site</AlternateText>
<Impressions>50</Impressions>
<Keyword>webhosting</Keyword>
</Ad>
</Advertisements>

In the following example we declare an AdRotator control in an .aspx file. Then we create an event handler for the AdCreated event, in the .aspx file, to override the value of the NavigateUrl element in the XML file:

<script runat="server">
  Sub change_url(sender As Object, e As AdCreatedEventArgs) 
    e.NavigateUrl="http://www.w3schools.com" 
  End Sub 
</script>
<html>
<body>
<form runat="server">
<asp:AdRotator id="ad1" Target="_self"
AdvertisementFile="Ad1.xml" runat="server"
OnAdCreated="change_url"/>
</form>
</body>
</html>


Back

Jump to: Top of Page or HOME or Printer Friendly Printer friendly page


Search W3Schools:


What Others Say About Us

Does the world know about us? Check out these places:

Dogpile Alta Vista MSN Google Excite Lycos Yahoo Ask Jeeves


We Help You For Free. You Can Help Us!


W3Schools is for training only. We do not warrant its correctness or its fitness for use. The risk of using it remains entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.

Copyright 1999-2002 by Refsnes Data. All Rights Reserved


Validate How we converted to XHTML Validate

Domain Name Registration
Domain Name
Registration & More!



Your own Web Site?

Read W3Schools
Hosting Tutorial



$15 Domain Name
Registration
Save $20 / year!



Advertise
at W3Schools

Only 0.5 CPM



SELECTED LINKS

University Online
Master Degree
Bachelor Degree


Web Software

The Future of
Web Development


Jobs and Careers

Web Security
Web Statistics
Web Standards


PARTNERS

W3Schools
TopXML
VisualBuilder
XMLPitstop
DevelopersDex
DevGuru
Programmers Heaven
The Code Project
Tek Tips Forum
ZVON.ORG
TopXML Search