ASP AdRotatorComponent


ASP AdRotator Component

Whenever a user enters the website or refreshes the page, the ASP AdRotator component creates an AdRotator object to display a different image. Information about the image is contained in a text file.

Note:AdRotator does not work in Internet Information Server 7 (IIS7).

Syntax

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


ASP AdRotator Example

Suppose we have a file named "ads.txt" as follows:

REDIRECT banners.asp
*
example.gif
http://www.example.com
Free Tutorials from EXAMPLE
50
xmlspy.gif
http://www.altova.com
XML Editor from Altova
50

In the above text file, the lines below the asterisk specify the name of the image to display, the hyperlink address, the alternate text for the image, and the display probability per hundred hits.

The first line of the above text file specifies the action to take when a visitor clicks an image. The redirect page (banners.asp) will receive a query string with the redirect URL.

Tip:To specify the height, width, and border of the image, you can insert the following code below REDIRECT:

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

The "banners.asp" file is as follows:

Example

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

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

Show Example »

Alright, that's all the content!


ASP AdRotator Properties

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

ASP AdRotator Methods

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

Other Extensions