ASP Content RotatorComponents (ASP 3.0)


ASP Content Rotator Component

The ASP Content Rotator component creates a ContentRotator object that displays a different content string each time a visitor enters the website or refreshes the page.

Information about the content strings is contained in a text file called a Content Schedule File.

Content strings can contain HTML tags, so you can display any type of content that HTML can render: text, images, colors, or hyperlinks.

Syntax

<%
Set cr=Server.CreateObject("MSWC.ContentRotator")
%>


ASP Content Rotator Examples

The example below displays different content each time a visitor browses the page.

First, create a text file named "textads.txt" and place it in a subfolder named "text".

"textads.txt":

%% #3
<h2>This is a great day!!</h2>

%% #3
<img src="smiley.gif.html">

%% #4
<a href="../index.html">Visit EXAMPLE</a>

Note the # number at the beginning of each content string. This number is an optional parameter that indicates the relative weight of the HTML content string. In the text file above, the Content Rotator has a 3/10 chance of displaying the first content string, a 3/10 chance of displaying the second content string, and a 4/10 chance of displaying the third string.

Then, create an ASP file and insert the following code:

Examples

<html>
<body>
<%
set cr=server.createobject("MSWC.ContentRotator")
response.write(cr.ChooseContent("text/textads.txt"))
%>
</body>
</html>

Demo Example »


ASP Content Rotator Component Methods

Methods Description Example
ChooseContent Retrieves and displays a content string. <%
dim cr
Set cr=Server.CreateObject("MSWC.ContentRotator")
response.write(cr.ChooseContent("text/textads.txt"))
%>

Output:

Smiley

GetAllContent Retrieves and displays all content strings from the text file. <%
dim cr
Set cr=Server.CreateObject("MSWC.ContentRotator")
response.write(cr.GetAllContent("text/textads.txt"))
%>

Output:

This is a great day!!

Smiley

Visit EXAMPLE


Other Extensions