[ Pobierz całość w formacie PDF ]
.For example, assume you have three snippets with weights of 33, 34, and 33.The first snippet would be selected 33% percent of the time, the second 34%percent, and the third 33% of the time.If a snippet s weight is zero, thatsnippet is never chosen.The default weight is 1.304 Chapter 16 Content Rotator ComponentASP in a Nutshell: A Desktop Quick Reference, eMatter EditionCopyright © 2000 O Reilly & Associates, Inc.All rights reserved.Accessory Files/Required DLL Files//CommentAn optional string of comments describing the HTML snippet or its relevance.It is for your use in maintaining the content schedule file and is neverdisplayed to the client.If a snippet requires more than one line of comments,start each comment with a double percent sign (%%) followed immediatelywith a double forward slash (//).HTMLContentStringThe actual HTML snippet that will be added to the client s display.This HTMLcan contain anything legal in HTML.However, you cannot have ASP script inthe HTMLContentString parameter.The Content Rotator component identi-fies the beginning and end of an HTML snippet using the double percentsigns.For this reason, you can have as many lines in your HTML snippet asyou like.The following is an example content schedule file containing five entries:%% #33 // This identifies the first snippet of HTML.%% // This is a second line of comments.Click hereto learn where the following movie line originated:"Most excellent."%% #5 // This is snippet two.Click hereto learn today's horoscope.%% #10 // This is snippet three.This line came from a great movie:"Humor.It is a difficult concept."%% #27 // This is snippet four.Comment your code; your replacement will appreciatethe work.%% #450 // This is snippet five.The probabilities that each snippet in the example content schedule file will beselected are shown in the following table:Snippet Weight Percentage1 33/525 6%2 5/525 1%3 10/525 2%4 27/525 5%5 450/525 86%Accessory Files/Required DLL Files 305ASP in a Nutshell: A Desktop Quick Reference, eMatter EditionCopyright © 2000 O Reilly & Associates, Inc.All rights reserved.Instantiating the Content Rotator ComponentInstantiating the Content Rotator ComponentTo create an object variable containing an instance of the Content Rotator compo-nent, use the Server object s CreateObject method.The syntax for the CreateObjectmethod is:Set objMyObject = Server.CreateObject(strProgId)where:" The objMyObjectparameter represents the name of a Content Rotator object." The strProgId parameter represents the programmatic ID (ProgID) for theContent Rotator component, which is IISSample.ContentRotator.ExampleHere are the current vote counts for favorite game:Doom312 Chapter 17 Counters ComponentASP in a Nutshell: A Desktop Quick Reference, eMatter EditionCopyright © 2000 O Reilly & Associates, Inc.All rights reserved.IncrementQuakeQuake 2NotesThe value of a counter is limited to the range of an integer.Note that the numberof counters held in the Counters component has little effect on the memory itholds on the web server, since the values of its counters are written to the harddrive.IncrementobjCounter.Increment(strCounterName)Increments a counter in the Counters component.If you attempt to increment acounter that does not yet exist, the counter is created and its value is set to 1.Thenew value of the counter is returned.ParametersstrCounterNameA string that represents the name of the counter variable you wish to manipu-late.This name can contain any Unicode character.ExampleThe following example assumes a Counters object (gobjOptionCounter) hasbeen instantiated elsewhere (see Instantiating the Counters Component earlier inthis chapter) and demonstrates the use of the Increment method.Favorite GamesYou are user numberto vote for Doom as your favorite game.%>.[additional HTML and code]RemoveobjCounter [ Pobierz caÅ‚ość w formacie PDF ]