Comments/Troubleshooting

The Counters component provides a powerful way to keep track of counters that are the same throughout your site. It can contain as many counter variables as memory permits, and each counter name can contain any Unicode character.

The most important thing to remember about the Counters component is that it is scopeless. This component is basically a repository for "ultraglobal" variables and should be treated accordingly. Any script in any application that alters a counter's value changes that counter's value for every other script that uses that counter for the entire site.

One important use for this component is to store and display user vote tallies. For example, several sites have a quick survey on their home pages. You are asked a simple question with a few radio buttons for your vote and a Submit button that allows you to see the vote tallies for each item for which you can vote. This way, you can maintain the counts for each option indefinitely. The examples in this chapter demonstrate this concept.

If you are using Windows 9x with Personal Web Server for your development, be aware that a Counters object is instantiated in the GLOBAL.ASA file created by Personal Web Server by default. For this reason, you can treat the Counters component exactly as if it were a built-in object, like the Application, Session, or Server objects. Note also that although the SCOPE parameter of the OBJECT tag that you use to instantiate a Counters object has a value of

Get ASP in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.