Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: random text


Message #1 by Roger Balliger <Roger@i...> on Tue, 28 Nov 2000 15:07:46 -0800
Can anyone provide me with a script which will look at a set of statements

(famous quotes for example) and display one at random when the page is

refreshed?  I would prefer to stick with VBScript however, JavaScript will

suffice.



Roger Balliger

Web Developer

The Insco Dico Group

(xxx) xxx-xxxx

roger@i...



Message #2 by simon@p... on Wed, 29 Nov 2000 05:01:59 -0000
hi



you can use the content rotator component. i'm sorry, but i don't have any

time right now to explain you. i'll write you tomorrow. just wanted to

give you some hope to survive the day :-)



simon

Message #3 by Robert Chartier <rchartierh@a...> on Wed, 29 Nov 2000 08:19:50 -0500
depends on where your data is coming from and how you will have it in the page.



for example...if your getting it from a database, then get your SQL to 

randomly choose a record, and use ADO to retrieve the record







At 02:24 AM 11/29/00, you wrote:

>Can anyone provide me with a script which will look at a set of statements

>(famous quotes for example) and display one at random when the page is

>refreshed?  I would prefer to stick with VBScript however, JavaScript will

>suffice.

>

>Roger Balliger

>Web Developer

>The Insco Dico Group

>(xxx) xxx-xxxx

>roger@i...

>

Robert Chartier

Author, AspFree.com

xxx-xxx-xxxx

rchartierh@a...

http://www.aspfree.com/devlinks

http://www.aspfree.com/authors/robert

http://www.aspalliance.com/nothingmn



Message #4 by simon@p... on Thu, 30 Nov 2000 02:57:14 -0000
hi



asp has a good component to display random jokes, quotes and whatever...

it's called ContentRotator.



here's all you have to do: (copied and pasted from MSDN)



<% 

Set Tip = Server.CreateObject("MSWC.ContentRotator") 

Tip.ChooseContent("/tips/tiprot.txt") 

%>



the ChooseContent() method inserts the random quote where you call it.







Syntax (of the text file that contains all the entries; in this case

tiprot.txt)



%% [#Weight] [//Comments]

ContentString

 

Parameters

Weight 

This optional parameter specifies a number between 0 and 65,535 that

indicates the relative weight of the HTML content string. The probability

of a particular content string being displayed by the ContentRotator

object can be expressed as the Weight of that content string divided by

the sum of Weight values for all entries in the Content Schedule file.

For example, if a Content Schedule file contained three content strings

with respective weights of 1, 3, and 4, the Content Rotator displays the

first content string one-eighth of the time, the second string

three-eighths of the time, and the third string half of the time.



A Weight of 0 will cause a content entry to be ignored. 



If Weight is not specified, the default value is 1. 



Comments 

This optional parameter contains comments about the entry. These comments

are for development use only and are not displayed to the user. If you

require more than one line of comments, you must start each additional

comment line with a line delimiter (%%) followed by a comment delimiter

(//).

ContentString 

The HTML content that the ContentRotator object displays. For example, you

can present a line of text, an image, or a sound.

ContentString may include one or more lines. The ContentRotator object

treats everything between blocks of double percent signs (%%) as a single

HTML content string.



Example

The following is an example of a Content Schedule file. Note that because

the content strings can contain HTML tags, you can display any type of

content that can be represented with HTML, including text, images, and

hyperlinks.



-------------content.txt--------------------

%% // Because no value is set for Weight, the default value is 1.

Don't run with scissors.



%% #2 // Content can be more that one line long

%% // Additional line of comments 

%% // Yet another line of comments

<FONT FACE="ARIAL,HELVETICA" SIZE="2">

  Let a

  <H1>smile</H1>

  be your umbrella.

</FONT>



%% #3 // This is our favorite image, so show it most often

<IMG SRC="/images/happy.gif">



%% 

Here's the <A HREF="secret.asp">secret link.</A>

 















i hope that helps you. if you prefer doing it with a database... just tell

me and i'll write you another example.



bye

Message #5 by Roger Balliger <Roger@i...> on Thu, 30 Nov 2000 08:40:36 -0800
Does this have to run on IIS 5, because I get an error when I run it on PWS?

The error message is below:



Server object error 'ASP 0177 : 800401f3' 



Server.CreateObject Failed 



Invalid class string 



-----Original Message-----

From: simon@p... [mailto:simon@p...]

Sent: Wednesday, November 29, 2000 6:57 PM

To: ASP Web HowTo

Subject: [asp_web_howto] Re: random text





hi



asp has a good component to display random jokes, quotes and whatever...

it's called ContentRotator.



here's all you have to do: (copied and pasted from MSDN)



<% 

Set Tip = Server.CreateObject("MSWC.ContentRotator") 

Tip.ChooseContent("/tips/tiprot.txt") 

%>



the ChooseContent() method inserts the random quote where you call it.







Syntax (of the text file that contains all the entries; in this case

tiprot.txt)



%% [#Weight] [//Comments]

ContentString

 

Parameters

Weight 

This optional parameter specifies a number between 0 and 65,535 that

indicates the relative weight of the HTML content string. The probability

of a particular content string being displayed by the ContentRotator

object can be expressed as the Weight of that content string divided by

the sum of Weight values for all entries in the Content Schedule file.

For example, if a Content Schedule file contained three content strings

with respective weights of 1, 3, and 4, the Content Rotator displays the

first content string one-eighth of the time, the second string

three-eighths of the time, and the third string half of the time.



A Weight of 0 will cause a content entry to be ignored. 



If Weight is not specified, the default value is 1. 



Comments 

This optional parameter contains comments about the entry. These comments

are for development use only and are not displayed to the user. If you

require more than one line of comments, you must start each additional

comment line with a line delimiter (%%) followed by a comment delimiter

(//).

ContentString 

The HTML content that the ContentRotator object displays. For example, you

can present a line of text, an image, or a sound.

ContentString may include one or more lines. The ContentRotator object

treats everything between blocks of double percent signs (%%) as a single

HTML content string.



Example

The following is an example of a Content Schedule file. Note that because

the content strings can contain HTML tags, you can display any type of

content that can be represented with HTML, including text, images, and

hyperlinks.



-------------content.txt--------------------

%% // Because no value is set for Weight, the default value is 1.

Don't run with scissors.



%% #2 // Content can be more that one line long

%% // Additional line of comments 

%% // Yet another line of comments

<FONT FACE="ARIAL,HELVETICA" SIZE="2">

  Let a

  <H1>smile</H1>

  be your umbrella.

</FONT>



%% #3 // This is our favorite image, so show it most often

<IMG SRC="/images/happy.gif">



%% 

Here's the <A HREF="secret.asp">secret link.</A>

 















i hope that helps you. if you prefer doing it with a database... just tell

me and i'll write you another example.



bye



Message #6 by Robert Chartier <rchartierh@a...> on Thu, 30 Nov 2000 13:16:19 -0500
the object has to be installed/registered on your machine.



MSWC.ContentRotator...isnt that part of tools.dll...?



either way, i dont believe PWS comes with those DLL's, thus you must either 

download and install them seperately or use IIS, or chose an alternative.







At 11:40 AM 11/30/00, you wrote:

>Does this have to run on IIS 5, because I get an error when I run it on PWS?

>The error message is below:

>

>Server object error 'ASP 0177 : 800401f3'

>

>Server.CreateObject Failed

>

>Invalid class string

>

>-----Original Message-----

>From: simon@p... [mailto:simon@p...]

>Sent: Wednesday, November 29, 2000 6:57 PM

>To: ASP Web HowTo

>Subject: [asp_web_howto] Re: random text

>

>

>hi

>

>asp has a good component to display random jokes, quotes and whatever...

>it's called ContentRotator.

>

>here's all you have to do: (copied and pasted from MSDN)

>

><%

>Set Tip = Server.CreateObject("MSWC.ContentRotator")

>Tip.ChooseContent("/tips/tiprot.txt")

>%>

>

>the ChooseContent() method inserts the random quote where you call it.

>

>

>

>Syntax (of the text file that contains all the entries; in this case

>tiprot.txt)

>

>%% [#Weight] [//Comments]

>ContentString

>

>Parameters

>Weight

>This optional parameter specifies a number between 0 and 65,535 that

>indicates the relative weight of the HTML content string. The probability

>of a particular content string being displayed by the ContentRotator

>object can be expressed as the Weight of that content string divided by

>the sum of Weight values for all entries in the Content Schedule file.

>For example, if a Content Schedule file contained three content strings

>with respective weights of 1, 3, and 4, the Content Rotator displays the

>first content string one-eighth of the time, the second string

>three-eighths of the time, and the third string half of the time.

>

>A Weight of 0 will cause a content entry to be ignored.

>

>If Weight is not specified, the default value is 1.

>

>Comments

>This optional parameter contains comments about the entry. These comments

>are for development use only and are not displayed to the user. If you

>require more than one line of comments, you must start each additional

>comment line with a line delimiter (%%) followed by a comment delimiter

>(//).

>ContentString

>The HTML content that the ContentRotator object displays. For example, you

>can present a line of text, an image, or a sound.

>ContentString may include one or more lines. The ContentRotator object

>treats everything between blocks of double percent signs (%%) as a single

>HTML content string.

>

>Example

>The following is an example of a Content Schedule file. Note that because

>the content strings can contain HTML tags, you can display any type of

>content that can be represented with HTML, including text, images, and

>hyperlinks.

>

>-------------content.txt--------------------

>%% // Because no value is set for Weight, the default value is 1.

>Don't run with scissors.

>

>%% #2 // Content can be more that one line long

>%% // Additional line of comments

>%% // Yet another line of comments

><FONT FACE="ARIAL,HELVETICA" SIZE="2">

>   Let a

>   <H1>smile</H1>

>   be your umbrella.

></FONT>

>

>%% #3 // This is our favorite image, so show it most often

><IMG SRC="/images/happy.gif">

>

>%%

>Here's the <A HREF="secret.asp">secret link.</A>

>

>

>

>

>

>

>

>

>i hope that helps you. if you prefer doing it with a database... just tell

>me and i'll write you another example.

>

>bye

>

>

Robert Chartier

Author, AspFree.com

xxx-xxx-xxxx

rchartierh@a...

http://www.aspfree.com/devlinks

http://www.aspfree.com/authors/robert

http://www.aspalliance.com/nothingmn




  Return to Index