HOME

ASP Tutorial
ASP HOME
ASP Introduction
ASP Install
ASP Syntax
ASP Variables
ASP Procedures
ASP Forms
ASP Cookies
ASP Session
ASP Application
ASP #include
ASP Global.asa

ASP Objects
ASP Response
ASP Request
ASP Application
ASP Session
ASP Server
ASP Error

ASP FileSystem
ASP TextStream
ASP Drive
ASP File
ASP Folder
ASP Dictionary

ASP Components
ASP AdRotator
ASP BrowserCap
ASP Content Linking
ASP Content Rotator

ASP Quick Ref

Examples/Quiz
ASP Examples
ASP Quiz Test

ADO
ADO Introduction

Resources
ASP Resources

Please visit our sponsors !

ASP AdRotator Component

previous next

Examples

Simple AdRotator Example
This example shows how to use the AdRotator component to display a different advertisement image, each time a user visits or refreshes the page.

AdRotator - The Images are Hyperlinks
This example shows how to use the AdRotator component to display a different advertisement image, each time a user visits or refreshes the page. In addition, the images are hyperlinks.


ASP AdRotator Component

The ASP AdRotator component creates an AdRotator object that displays a different image each time a user enters or refreshes a page. A text file includes information about the images.

Syntax

<%
set adrotator=server.createobject("MSWC.AdRotator")
adrotator.GetAdvertisement("textfile.txt")
%>


Example

Assume we have a file called "banners.asp". It looks like this:

<html>
<body>
<%
set adrotator=Server.CreateObject("MSWC.AdRotator")
response.write(adrotator.GetAdvertisement("ads.txt"))
%>
</body>
</html>

And a file "ads.txt" that looks like this:

*
w3schools.gif
http://www.w3schools.com/
Visit W3Schools
80
microsoft.gif
http://www.microsoft.com/
Visit Microsoft
20

The lines below the asterisk in the file "ads.txt" specifies the images to be displayed, the hyperlink addresses, the alternate text (for the images), and the display rates in percent of the hits. We see that the W3Schools image will be displayed for 80 % of the hits and the Microsoft image will be displayed for 20 % of the hits in the text file above.

Note: To get the links to work when a user clicks on them, we will have to modify the file "ads.txt" a bit:

REDIRECT banners.asp
*
w3schools.gif
http://www.w3schools.com/
Visit W3Schools
80
microsoft.gif
http://www.microsoft.com/
Visit Microsoft
20

The redirection page (banners.asp) will now receive a querystring with a variable named URL containing the URL's to redirect to.

Note: To specify the height, width, and border of the image, you can insert the following lines under REDIRECT:

REDIRECT banners.asp
WIDTH 468
HEIGHT 60
BORDER 0
*
w3schools.gif
...
...

The last thing to do is to add some lines of code to the "banners.asp" file:

<%
url=Request.QueryString("url")
If url<>"" then Response.Redirect(url)
%>

<html>
<body>
<%
set adrotator=Server.CreateObject("MSWC.AdRotator")
response.write(adrotator.GetAdvertisement("textfile.txt"))
%>
</body>
</html>

That's all!!


Properties

Property Description Example
Border Specifies the size of the borders around the advertisement <%
set adrot=Server.CreateObject("MSWC.AdRotator")
adrot.Border="2"
Response.Write(adrot.GetAdvertisement("ads.txt"))
%>
Clickable Specifies whether the advertisement is a hyperlink <%
set adrot=Server.CreateObject("MSWC.AdRotator")
adrot.Clickable=false
Response.Write(adrot.GetAdvertisement("ads.txt"))
%>
TargetFrame Name of the frame to display the advertisement <%
set adrot=Server.CreateObject("MSWC.AdRotator")
adrot.TargetFrame="target='_blank'"
Response.Write(adrot.GetAdvertisement("ads.txt"))
%>

Methods

Method Description Example
GetAdvertisement Returns HTML that displays the advertisement in the page <%
set adrot=Server.CreateObject("MSWC.AdRotator")
Response.Write(adrot.GetAdvertisement("ads.txt"))
%>


previous next

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

IISCart
ASP Ecommerce & Shopping Cart


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