MSWC.AdRotator  component

In order to use this component we need a file with the ads we want to rotate in our page. Check this example:
 

MylistOfAds.txt
*
/image1.gif
http://www.domain1.com/
Visit domain1.com
30
/image2.gif
http://www.domain2.com/
Visit domain2.com
70

In the first line we must include the character  "*", and starting in second line, each four lines we will include information related to one ad (first ad in red, second ad in blue).
Information related to each ad must be write in four lines as shown above. Ad related information will be introduced in the order used in the example:

A conventional link will be like this:
    <A HREF="http://www.domain1.com"><IMG SRC="/image1.gif"  ALT="Visit domain1.com"></A>
 

To display those ads in our page we will include the following code to our page (explanation in the bottom):
 
 

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

<html>
<body>
<%
set adrotator=Server.CreateObject("MSWC.AdRotator")
' Border of image
adrotator.Border="0"
'Image is a hiperlink or not
adrotator.Clickable=true
' Specify target
adrotator.TargetFrame="target=_new"
' The link in included
response.write(adrotator.GetAdvertisement("/cgi-bin/MylistOfAds.txt"))
%>
</body>
</html>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

First we will check the code in lines 9 to 18. This code will be used to ad a imagen link to our page.

The link written to our response page will be like this one (note the size of the image is predefined):
<A HREF="?url=http://www.domain1.com/&image=/image1.gif" TARGET="target=_new">
<IMG SRC="/image1.gif" ALT="Visit domain1.com" WIDTH=440 HEIGHT=60 BORDER=0>
</A>
 
As shown in this example, when clicking on the imagen, the url we will visit will be "?url=http://www.domain1.com/&image=/image1.gif", which is also the page where we have included our ad rotation script. That is why we will need to add in the first part of our page the code shown in lines 1 to 4.

AspTutorial.info.