• 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, including
the pecentage of impressions per banner from the collection.
Syntax
<%
set adrotator=server.createobject("MSWC.AdRotator")
adrotator.GetAdvertisement("BannerList.txt")
%>
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("MyAds.txt"))
%> |
Clickable |
Specifies whether the advertisement is a hyperlink |
<%
set adrot=Server.CreateObject("MSWC.AdRotator")
adrot.Clickable=false
Response.Write(adrot.GetAdvertisement("MyAds.txt"))
%> |
TargetFrame |
Name of the frame to display the
advertisement |
<%
set adrot=Server.CreateObject("MSWC.AdRotator")
adrot.TargetFrame="target='_blank'"
Response.Write(adrot.GetAdvertisement("MyAds.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("MyAds.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("MyAds.txt"))
%>
</body>
</html> |
The file "MyAds.txt" looks like this:
*
SeeBAY.jpg
http://www.clothesandthings.com/Datalinks
SeeBAY - The Research Tool for eBay
30
C&Tbanner.gif
http://www.clothesandthings.com/
Visit Clothes And Things
70 |
The lines below the asterisk in the file "MyAds.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 Clothes And Things image will be displayed for
70 % of the hits and the SeeBAY image will be displayed for 30
% of the hits in the text file above.
To get the links to work when a user clicks on
them, we will have to modify the file "MyAds.txt" a
little:
REDIRECT banners.asp
*
SeeBAY.jpg
http://www.clothesandthings.com/Datalinks
SeeBAY - The Research Tool for eBay
30
C&Tbanner.gif
http://www.clothesandthings.com/
Visit Clothes And Things
70 |
The redirection page (banners.asp) will now receive a
querystring with a variable named URL containing the URL 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 500
HEIGHT 100
BORDER 0
*
SeeBAY.jpg
...
... |
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("MyAds.txt"))
%>
</body>
</html>
|
That's it! Enjoy this object!
View a Demo
|