Link:http://output.to/sideway/default.asp?qno=130200008 ASP Server Component, Pre-made Function, Counters Component ASP Server ComponentsSome of the ASP server components are the common features found in dynamic web pages. These base ASP server components are provided to enrich the pre-made functions of ASP technology for making dynamic and interactive web pages. However, some IIS pre-made components are not installed for all version of IIS. Ad Rotator, Browser Capabilities, Content Linker, Content Rotator, Counters, Logging Utility, My Info, Page Counter, Status, and tools are not installed with IIS 6.0. However, if you upgrade your Web server from a previous version of IIS, the pre-made components are not removed. Some IIS pre-made components, ASP content rotator and nextlink, are deprecated in IIS7. And most IIS pre-made components are either not installed with IIS7 or their usage is not supported. Counters componentThe Counters component can be used to create a Counters object that acts as a HTML tags holder on an ASP page for controlling any number of individual counters on a web page. The function of the Counters object is to create, store, increase, and retrieve any number of individual counters on the web page each time when an user opens or reloads the web page. Each counter is a persistent value that contains an integer. Once a counter is created by the set method, the counter persists until the counter is removed by the remove methods. Each counter does not increase automatically on an event like a page hit. The value of a counter can only be manually set or increased using the set and increment methods. Only one instance of Counters object is needed for a web site. Therefore the Counters object can be defined in the global.asa at the root directory of web application. And individual created counters are not limited in scope. An individual counter created on any page of the web site can also be retrieved or manipulated by any other page on the web site using methods of the Counters Component. All individual conuters created by the Counters Object are stored in a single text file, e.g. Counters.txt, which is located in the same directory as the counters.dll file. For example, an individual counter can be increased and displayed on more than one page on the web site. In other words, whenever there is an increment of the individual counter due to one page on the web site, the changes on the individual counter can be displayed on the related pages simultaneously when the page is opened or reloaded. The change in a Counters.txt File may need to restart the IIS services in ordered to make the changes by the Counters Object become effective. The Counters.txt File may be located in %WINDIR%\inetsrv\Data or %WINDIR%\inetsrv\ directory depending on the verson of IIS and the operating system. File NameThe file name of the Content Rotator component is Controt.dll. A file, Counters.txt is used to store all individual counters on a site. Counters.txt is a UTF8-encoded file. And therefore any Unicode characters can be used in a counter name. SyntaxThe Counters object is defined by a HTML <object> tag. Only one Counters object is needed for a site. A single Counters object can create any number of individual counters. Therefore the Counters object can be created only one time on the server by adding the <object> tag to the Global.asa in the root directory.
<OBJECT ParametersCountersName The parameter "CountersName" is the name assigned to the instance of the Counters object created by the HTML <object> tag. RemarkThe Content Rotator component does not work with Internet Information Server 7 (IIS7). Counters.Get MethodCounters.Get method is used to retrieve the current value of the specified individual counter. If the specified individual counter doesnot exist, the Counters.Get method creates the specified individual counter and sets the value of the specified individual counter to 0. Syntax SyntaxCountersName.Get( CounterName ) ParametersCountersName The parameter "CountersName" is the name of the instance of the Counters object to be set. CounterName The parameter "CounterName" is used to specified the name of the individual counter to be retrieved. Counters.Increment MethodCounters.Increment method is used to add 1 to the current value of the specified individual counter and then retrieve the new value of the specified individual counter. If the specified individual counter doesnot exist, the Counters.Get method creates the specified individual counter and sets the value of the specified counter to 1. SyntaxCountersName.Increment( CounterName ) ParametersCountersName The parameter "CountersName" is the name of the instance of the Counters object to be set. CounterName The parameter "CounterName" is used to specified the name of the individual counter to be retrieved. Counters.Remove MethodCounters.Remove method is used to remove the specified individual counter from the Counters object, and deletes the specified individual counter from the Counters.txt file. SyntaxCountersName.Remove( CounterName ) ParametersCountersName The parameter "CountersName" is the name of the instance of the Counters object to be set. CounterName The parameter "CounterName" is used to specified the name of the individual counter to be retrieved. Counters.Set MethodCounters.Set method is used to set the value of the specified individual counter according to the value of the specified integer and then retrieve the new value of the specified individual counter. If the specified individual counter doesnot exist, the Counters.Set method creates the specified individual counter and sets the value of the specified individual counter to the value of the specified integer. SyntaxCountersName.Set( CounterName,int ) ParametersCountersName The parameter "CountersName" is the name of the instance of the Counters object to be set. CounterName The parameter "CounterName" is used to specified the name of the individual counter to be retrieved. int The parameter "int" is used to specified the new integer value of the specified individual counter in Parameter, CounterName, to be retrieved.. Examples
|
Sideway BICK Blog 14/02 |