ASP Content Rotator Component (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 site or refreshes the page.
Information about the content strings is contained in a text file called the 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 Example
The example below displays different content each time a visitor views the page.
First, create a text file named "textads.txt" and place it in a subfolder named "text".
"textads.txt":
%% #3
This is a great day!!
%% #3
%% #4
Note the # number at the start 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 three-in-ten chance of displaying the first content string, a three-in-ten chance of displaying the second, and a four-in-ten chance of displaying the third.
Then, create an ASP file and insert the code below:
Example
<%
set cr=server.createobject("MSWC.ContentRotator")
response.write(cr.ChooseContent("text/textads.txt"))
%>
Demo Example »
ASP Content Rotator Component Methods
| Method | Description | Example |
|---|---|---|
| ChooseContent | Retrieves and displays a content string. | <% |
dim cr
Set cr=Server.CreateObject("MSWC.ContentRotator")
response.write(cr.ChooseContent("text/textads.txt"))
%> 输出:
| | GetAllContent | Retrieves and displays all content strings in the text file. | <% dim cr Set cr=Server.CreateObject("MSWC.ContentRotator") response.write(cr.GetAllContent("text/textads.txt")) %>
Output:
This is a great day!!
