Sideway BICK BlogSideway BICK BLOG from Sideway

A Sideway to Sideway Home

Link:http://output.to/sideway/default.asp?qno=130200008

ASP Server Component, Pre-made Function, Counters Component

ASP Server Components

Some 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 component

The 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 Name

The 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.

Syntax

The 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
RUNAT=Server
SCOPE=Application
ID=CountersName
PROGID="MSWC.Counters">
</OBJECT>

Parameters

CountersName

The parameter "CountersName" is the name assigned to the instance of the Counters object created by the HTML <object> tag.

Remark

The Content Rotator component does not work with Internet Information Server 7 (IIS7).

Counters.Get Method

Counters.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 Syntax

CountersName.Get( CounterName )

Parameters

CountersName

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 Method

Counters.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.

Syntax

CountersName.Increment( CounterName )

Parameters

CountersName

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 Method

Counters.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.

Syntax

CountersName.Remove( CounterName )

Parameters

CountersName

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 Method

Counters.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.

Syntax

CountersName.Set( CounterName,int )

Parameters

CountersName

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

  • Example of making use of Counters component to create an instance of Counters object with ID equal to "Counters" by a HTML <object> tag in the Global.asa in the root directory of the web site for all ASP pages below.

    Global.asa:

    <OBJECT
    RUNAT=Server
    SCOPE=Application
    ID=Counters
    PROGID="MSWC.Counters">
    </OBJECT>

  • Example of making use of Counters.Set method to create an individual counter with name called "SiteCounterA" and assign a specified integer value, 10 to the counter. And then the value of the individual counter, SiteCounterA is retrieved and displayed on the web page.

    ASP Page:

    Setting the SiteCounterA to <%= Counters.Set("SiteCounterA", 10)%>.

  • Example of making use of Counters.Increment method to increase an individual counter with name called "SiteCounterA" by one and then the value of the individual counter, SiteCounterA is retrieved and displayed on the web page.

    ASP Page:

    The SiteCounterA is increased by 1 to
        <%=  Counters.Increment("SiteCounterA")%>.

  • Example of making use of Counters.Set method to set the individual counter with name "SiteCounterA" to the specified integer value, 20. And then making use of Counters.Get method to is retrieve and display the value of the individual counter, SiteCounterA on the web page.

    ASP Page:

    <% Counters.Set "SiteCounterA", 20 %>
    The SiteCounterA is set to <%= Counters.Get("SiteCounterA")%>.

  • Example of making use of Counters.Remove method to remove the individual counter, SiteCounterA from the Counters object, and deletes the individual counter, SiteCounterA  from the Counters.txt file. And then making use of Counters.Get method to is retrieve and display the value of the  individual counter, SiteCounterA on the web page.

    ASP Page:

    <% Counters.Remove("SiteCounterA") %>
    The SiteCounterA becomes <%= Counters.Get("SiteCounterA")%> because the  SiteCounterA is removed and doesnot exist .

Previous Month  FEB  2013  Next Month
SMTWTFS
12
3456789
10111213141516
17181920212223
2425262728

Previous Month  SEP  2016  Next Month
SMTWTFS
123
45678910
11121314151617
18192021222324
252627282930

Sideway BICK Blog

14/02


Copyright © 2000-2020 Sideway . All rights reserved Disclaimerslast modified on 26 January 2013