Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

ASP AdRotator

ASP AdRotator component


ASP AdRotator component

Each time a user enters a website or refreshes a page, the ASP AdRotator component creates an AdRotator object to display a different image. Information about the images 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" that looks like this:

REDIRECT banners.asp

runoob.gif

http://www.runoob.com

Free Tutorials from RUNOOB

50

xmlspy.gif

http://www.altova.com

XML Editor from Altova

50

In the text file above, the lines below the model specify the name of the image to display, the hyperlink address, the replacement text for the image, and the display probability per hundred clicks.

The first line of the text file above specifies the action to take when a visitor clicks the image. The redirect page (banners.asp) will receive a query string containing 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

runoob.gif

...

The "banners.asp" file looks like this:

Example

<%

url=Request.QueryString("url")

If url<>"" then Response.Redirect(url)

%>

<%

set adrotator=Server.CreateObject("MSWC.AdRotator")

response.write(adrotator.GetAdvertisement("textfile.txt"))

%>

Demo Example »

All right, that is everything above!


ASP AdRotator properties

property Description Example
Border Specifies the size of the border around the ad. <%
 set adrot=Server.CreateObject("MSWC.AdRotator")       

 adrot.Border="2"       

 Response.Write(adrot.GetAdvertisement("ads.txt"))       

 %> |

| Clickable | Specifies whether the ad itself is a hyperlink. | <%
set adrot=Server.CreateObject("MSWC.AdRotator")
adrot.Clickable=false
Response.Write(adrot.GetAdvertisement("ads.txt"))
%> | | TargetFrame | The name of the frame in which the ad is displayed. | <%
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 ad on the page. <%
 set adrot=Server.CreateObject("MSWC.AdRotator")       

 Response.Write(adrot.GetAdvertisement("ads.txt"))       

 %> |