Visual InterDev

Random Advertisement Sample

See Also      

This sample shows how to create a random display on your page.

Behind the Scenes

This sample uses three files:

RandomAd.asp

RandomAd.asp uses just two lines of script to display the advertisement. The first line creates the object reference to the AdRotator component and the second line gets information from the RandomAd.txt file to display the ad:

<%Set ad = Server.CreateObject("MSWC.AdRotator")%>
<%= ad.GetAdvertisement("RandomAd.txt") %>  

RandomAd.txt

RandomAd.txt is used as the rotator schedule file. The rotator schedule file contains information that the Advertisement Rotator component uses to manage and display the various advertisement images. In it, you specify the details for the advertisements, such as the size of the advertisement space, the image files to use, and the percentage of time that each file should be displayed.

The rotator schedule file has two sections:

A line containing only an asterisk separates the two sections (*). Below is a portion of the RandomAd.txt file that shows one advertisement entry:

REDIRECT AdRedir.asp
WIDTH 468
HEIGHT 60
BORDER 1
*
../images/rollover.gif
http://www.microsoft.com/frontpage
Free Beta Copy of Microsoft FrontPage 98
2 

AdRedir.asp

AdRedir.asp redirects users to the appropriate URL after they have clicked on the advertisement.

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

You can also include script in the redirection file to count the number of users that have clicked on a particular advertisement and save this information to a file on the server.