Sun Chili!Soft ASP Sun Chili!Soft
ASP Sun Microsystems

 

ASP Counters Component Get Method

The Get method takes the name of a counter and returns the current value of the counter. If the counter doesn't exist, the method creates it and sets it to 0.

Arguments: ASP Counters Component Get Method

CounterName

A string containing the name of the counter.

Examples: ASP Counters Component Get Method

Display the value a counter with <%= Counters.Get(CounterName) %>. Assign the value of the counter to a variable with <% countervar = Counters.Get(CounterName) %>.

The following script displays the vote tally from a poll about favorite colors.

<%

If colornumber = "1" Then  

Counters.Increment("greencounter")  

Else  

If colornumber = "2" Then  

Counters.Increment("bluecounter")  

Else  

If colornumber = "0" Then  

Counters.Increment("redcounter")  

End If  

End If  

End If  

%>

<P>Current vote tally:

<P>red: <% =Counters.Get("redcounter") %>

<P>green: <% = Counters.Get("greencounter") %>

<P>blue: <% = Counters.Get("bluecounter") %>

Copyright 2002 Sun Microsystems, Inc. All rights reserved. Legal Notice.