ASP comes with a ready to use 'Ad Rotator' component. We can use this to create a rotating banner management system. All we need are the following 3 files.
Call this file banner_ad.asp
The purpose of this file is to display the random advertisement.
<%
'declare your variables
dim varad, objAd
'create an instance of the Rotator object
and assign variable
Set objAd = Server.CreateObject("MSWC.AdRotator")
'make sure the page will open up in a new
browser
objAd.TargetFrame="TARGET=_BLANK"
'call the GetAdvertisement method and assign
all details to variable
varAd = objAd.GetAdvertisement("adrotator.txt")
'display the banner and its details
Response.Write varAd
%>
Call this next file redirect.asp
Once the user clicks on one of the banners an associated url is sent through the querystring to this page. This file will then redirect the user to the url passed.
<%
response.redirect Request.querystring("url")
%>
The third file is Adrotator.txt
As you can see from the file extension this is a text file which
we can break down into 2 parts.
The first part holds general information with 4 parameters, namely
the width of the borders, the height and width of the banners
and the page that will act as the redirection page ( the page
that will be sent the url through the querystring ).
In our case this will be redirect.asp which is in the same folder.
Next we have a * which separates the parts. Dont forget it.
In part2 we have the image source, this can be relative or absolute,
the url to be sent to when the user clicks the url, the alternate
text and the frequency of the advertisement in terms of percentage.
Just note that below the url's may be the same, though for your purposes you can simply change them.
REDIRECT redirect.asp
border 0
height 60
width 468
*
http://www.codefixer.com/advertising/BANNER1.gif
http://www.codefixer.com
Resources and Tutorials for the ASP developer
40
http://www.codefixer.com/advertising/BANNER2.gif
http://www.codefixer.com
The best ASP site on the net
50
http://www.codefixer.com/advertising/BANNER3.gif
http://www.codefixer.com
ASP for the beginner to intermediate ASP developer
10
You could use an include file to call banner_ad.asp
Make sure the folder advertising is in the root web directory
of your site when you call the file, you can then include this
in any file on your site.
<!--#include virtual="/advertising/banner_ad.asp"-->
Download the source files - advertising.zip
Here's a tip on improving this system click
here.
Plug and play ASP membership script that integrates with PayPal to let you charge recurring membership fees.
Get your best asp web hosting provider now and save 25%