Latest web development tutorials

ASP Content Rotator

ASP Content Rotator Component

ASP Content Rotator component creates a ContentRotator object whenever visitors enter the site, or refresh the page, the object will display a different content string.

Information about the content of the string is contained in a file called content directory (Content Schedule File) text file.

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

grammar

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


ASP Content Rotator examples

Whenever a visitor browsing the web, the following examples will show different content.

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

"Textads.txt":

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

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

%% #4
<a href="http://www.w3cschool.cc">Visit W3CSchool.cc</a>

Note # number each content string starting position. This number is an optional parameter used to indicate the relative weight of the HTML content string weight. In the above text file, Content Rotator has a chance to show the first three tenths of a content string, has a chance to three tenths of a second to display the contents of a string of four tenths has a chance to show a 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>

The demonstration >>


The method of ASP Content Rotator component

方法 描述 实例
ChooseContent 获取并显示某个内容字符串。 <%
dim cr
Set cr=Server.CreateObject("MSWC.ContentRotator")
response.write(cr.ChooseContent("text/textads.txt"))
%>

输出:

Smiley

GetAllContent 取回并显示文本文件中所有的内容字符串。 <%
dim cr
Set cr=Server.CreateObject("MSWC.ContentRotator")
response.write(cr.GetAllContent("text/textads.txt"))
%>

输出:

This is a great day!!

Smiley

Visit W3CSchool.cc