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

118 lines
4.0 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>Set</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="_set_counters"></A><SUP></SUP>Set</H2>
<P>The <B>Set </B>method takes the name of a counter and an integer, sets the counter to the value of the integer, and returns the new value. If the counter doesn't exist, <B>Counters.Set </B>creates it and sets it to the value of the integer.</P>
<P>To retrieve the value of a counter, use <B>Counters.Get</B>. To increment a counter by 1, use <B>Counters.Increment</B>. </P>
<H6>Syntax</H6>
<P><I>Counters</I><B>.Set( </B><I>CounterName</I><B>, </B><I>int </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.<BR>
</DD>
<DT><I>int</I></DT>
<DD>The new integer value for <I>CounterName</I>.</DD>
</DL>
<H6>Example</H6>
<P>The following code resets the votes: </P>
<P>--- Counters_Set.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;%
red = Request.QueryString("red")
green = Request.QueryString("green")
blue = Request.QueryString("blue")
' The Counters object was instantiated in Global.asa.
If IsNumeric(red) Then
Counters.Set "redcounter", red
End If
If IsNumeric(green) Then
Counters.Set "greencounter", green
End If
If IsNumeric(blue) Then
Counters.Set "bluecounter", blue
End If
%&gt;
&lt;H3&gt;Doctor the Vote:&lt;/H3&gt;
&lt;FORM NAME="Doctoring the Vote" METHOD="GET" ACTION="Counters_Set.asp"&gt;
Red &lt;input type="TEXT" NAME="red"&gt;&lt;BR&gt;
Green &lt;input type="TEXT" NAME="green"&gt;&lt;BR&gt;
Blue &lt;input type="TEXT" NAME="blue"&gt;&lt;BR&gt;
&lt;BR&gt;&lt;INPUT TYPE="SUBMIT" VALUE="Submit"&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;/BODY&gt;
&lt;/HTML&gt;
</CODE></PRE>
<H6>See Also</H6>
<P><A HREF="/iishelp/iis/htm/asp/comp1c37.htm">Get</A>, <A HREF="/iishelp/iis/htm/asp/comp46lv.htm">Increment</A>, <A HREF="/iishelp/iis/htm/asp/comp02cz.htm">Remove</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>