HOW TO: Use the ASP PageCounter Component in FrontPage 2002 (318275)



The information in this article applies to:

  • Microsoft FrontPage 2002

This article was previously published under Q318275

SUMMARY

Use this step-by-step guide to set up a Web page with a Page Counter installable component for Active Server Pages (ASP).

The Page Counter component creates a PageCounter object that counts and displays the number of times a Web page has been opened. At regular intervals the object writes the number of hits to a text file.

back to the top


Creating a Page and Adding the Page Counter Component Code

  1. On a Web server running Internet Information Services (IIS), start FrontPage and then open a Web.
  2. Start a new page. To do this, click the New Page button on the FrontPage toolbar.
  3. Switch to HTML view.
  4. Insert the following code before the opening <body> tag to create an object for the counter, to increment the hit count, and to store the hit count in a variable:
    <%
        Dim lngHits
        Dim objCounter
    
        Set objCounter = Server.CreateObject("MSWC.PageCounter")
        objCounter.PageHit
        lngHits = objCounter.Hits
        Set objCounter = Nothing
    %>
    					
  5. Switch back to Normal view.
back to the top


Using the Hit Counter on the Page

  1. Type You are visitor followed by a space.
  2. Insert an HTML Markup Web component and add the ASP code that will use the hit counter object. To do this, perform the following steps:
    1. On the Insert menu, click Web Component.
    2. In the Component Type list, click Advanced Controls.
    3. In the Choose a control list, click HTML.
    4. Click Finish.
  3. In the HTML Markup dialog box, type the following code:
    <%=lngHits%>
    						
    This code retrieves the current hit count that is stored in the variable created in the code example in Step 1.
  4. Click OK to close the HTML Markup dialog box.
back to the top


Saving and Previewing the Page

  1. On the File menu, click Save.
  2. Name the file CounterText.asp and click Save.
  3. On the File menu, click Preview in Browser.
  4. Click Preview.
If you refresh the page in your browser, you will see the count value increment.

NOTE: Because the output from the counter object is text, changing the fonts or colors for the page also changes the counter.

For more information about changing the fonts or colors, click Microsoft FrontPage Help on the Help menu, type fonts or colors in the Office Assistant or the Answer Wizard, and then click Search to view the topic.
back to the top


MORE INFORMATION

Active Server Pages (ASP) for IIS come with several built-in objects, such as the Response and Request objects. In addition to these objects, IIS has several "Installable Components" that you can use with ASP. The Page Counter Component allows you to create text-based counters for use on Web pages.

back to the top

REFERENCES

For additional information about installable components for ASP, view the IIS documentation at the following Microsoft Web site: back to the top

Modification Type:MajorLast Reviewed:6/30/2004
Keywords:kbhowto kbHOWTOmaster KB318275