2025-04-27 07:49:33 -04:00

103 lines
3.6 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=Windows-1252">
<TITLE>Get</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
TempString = navigator.appVersion
if (navigator.appName == "Microsoft Internet Explorer"){
// Check to see if browser is Microsoft
if (TempString.indexOf ("4.") >= 0){
// Check to see if it is IE 4
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/coua.css">');
}
else {
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/cocss.css">');
}
}
else if (navigator.appName == "Netscape") {
// Check to see if browser is Netscape
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/coua.css">');
}
else
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/cocss.css">');
//-->
</script>
<SCRIPT LANGUAGE="VBScript">
<!--
Sub Window_OnLoad()
Dim frmContents
On Error Resume Next
If Not Parent Is Nothing Then
Set frmContents = Parent.Contents
If Not frmContents Is Nothing Then
frmContents.Window.TOCSynch_Click
End If
End If
End Sub
//--></SCRIPT><META NAME="DESCRIPTION" CONTENT="Internet Information Services reference information">
<META HTTP-EQUIV="PICS-Label" CONTENT='(PICS-1.1 "<http://www.rsac.org/ratingsv01.html>" l comment "RSACi North America Server" by "inet@microsoft.com <mailto:inet@microsoft.com>" r (n 0 s 0 v 0 l 0))'>
<META NAME="MS.LOCALE" CONTENT="EN-US">
<META NAME="MS-IT-LOC" Content="Internet Information Services">
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H2><A NAME="_get_counters"></A><SUP></SUP>Get</H2>
<P>The <B>Get </B>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.</P>
<H6>Syntax</H6>
<P><I>Counters</I><B>.Get(</B><I>CounterName</I><B>)</B></P>
<P>&nbsp;</P>
<H6>Parameters</H6>
<DL>
<DT><I>CounterName</I></DT>
<DD>A string containing the name of the counter.</DD>
</DL>
<H6>Example</H6>
<P>Display the value of a counter with <CODE>&lt;%= Counters.Get(<I>CounterName</I>) %&gt;</CODE>. The following script displays the vote tally from a poll about favorite colors. </P>
<P>--- Counters_Get.asp ---</P>
<PRE><CODE>&lt;HTML&gt;
&lt;HEAD&gt;&lt;TITLE&gt;Voting for Colors&lt;/TITLE&gt;&lt;/HEAD&gt;
&lt;BODY&gt;
&lt;%
vote = Request.QueryString("color")
' The Counters object was instantiated in Global.asa.
Counters.Increment(vote &amp; "counter")
%&gt;
&lt;H3&gt;Vote for your Favorite Color:&lt;/H3&gt;
&lt;FORM NAME="Voting for Colors" METHOD="GET" ACTION="Counters_Get.asp"&gt;
&lt;input type="RADIO" NAME="color" VALUE="red"&gt;Red
&lt;input type="RADIO" NAME="color" VALUE="green"&gt;Green
&lt;input type="RADIO" NAME="color" VALUE="blue"&gt;Blue
&lt;BR&gt;&lt;INPUT TYPE="SUBMIT" VALUE="Submit Vote"&gt;
&lt;/FORM&gt;
&lt;H3&gt;Current Vote Tally:&lt;/H3&gt;
Red: &lt;% =Counters.Get("redcounter") %&gt;&lt;BR&gt;
Green: &lt;% = Counters.Get("greencounter") %&gt;&lt;BR&gt;
Blue: &lt;% = Counters.Get("bluecounter") %&gt;&lt;BR&gt;
&lt;/BODY&gt;
&lt;/HTML&gt;
</CODE></PRE>
<H6>See Also</H6>
<P><A HREF="/iishelp/iis/htm/asp/comp46lv.htm"><B>Increment</B></A>, <A HREF="/iishelp/iis/htm/asp/comp02cz.htm"><B>Remove</B></A>, <A HREF="/iishelp/iis/htm/asp/comp1q0j.htm"><B>Set</B></A> </P>
<hr class="iis" size="1">
<p align="center"><em><a href="../../../common/colegal.htm">&copy; 1997-2001 Microsoft Corporation. All rights reserved.</a></em></p>
</BODY>
</HTML>