ASP Content Rotator
ASP Content Rotator Component
The ASP Content Rotator component creates a ContentRotator object that displays a different content string every time a visitor enters the website or refreshes the page.
Information about the content string is contained in a text file called the Content Schedule File (Content Schedule File).
Content strings can contain HTML tags, allowing you to 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 every time a visitor browses the web page.
First, create a text file named "textads.txt" and place it in a subfolder named "text".
"textads.txt":
<h2>This is a great day!!</h2>
%% #3
<img src="../style/images/smiley.gif">
%% #4
<a href="http://www .w3cschool.cc">Visit W3CSchool.cc</a>
Please note the # number at the beginning of each content string. This number is an optional parameter used to indicate the relative weight of the HTML content string. In the text file above, the Content Rotator has a 3 in 10 chance of displaying the first content string, a 3 in 10 chance of displaying the second content string, and a 4 in 10 chance of displaying the third string.
Then, create an ASP file and insert the following code:
Instance
<html> <body> <% set cr=server.createobject("MSWC.ContentRotator") response.write(cr.ChooseContent("text/textads.txt")) %> </body> </html>
Run Example»
Click the "Run Instance" button to view the online instance
Methods of ASP Content Rotator component
Method | Description | Instance |
---|---|---|
ChooseContent | Get and display a certain content string. | <% dim cr Set cr=Server.CreateObject("MSWC.ContentRotator") response.write(cr.ChooseContent("text/textads.txt")) %> Output: |
Retrieve and display all content in the text file content string. | <% | dim cr Set cr=Server.CreateObject("MSWC.ContentRotator") response.write(cr.GetAllContent("text/textads.txt")) %> Output:This is a great day!! ##Visit W3CSchool.cc |