Microsoft KB Archive/318275

= HOW TO: Use the ASP PageCounter Component in FrontPage 2002 =

Article ID: 318275

Article Last Modified on 3/29/2007

-

APPLIES TO


 * Microsoft FrontPage 2002 Standard Edition

-



This article was previously published under Q318275





For a Microsoft FrontPage 2000 version of this article, see 309008.

IN THIS TASK
SUMMARY
 * Creating a Page and Adding the Page Counter Component Code
 * Using the Hit Counter on the Page
 * Saving and Previewing the Page

MORE INFORMATION REFERENCES



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
 On a Web server running Internet Information Services (IIS), start FrontPage and then open a Web. Start a new page. To do this, click the New Page button on the FrontPage toolbar. Switch to HTML view.  Insert the following code before the opening 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(&quot;MSWC.PageCounter&quot;) objCounter.PageHit lngHits = objCounter.Hits Set objCounter = Nothing %>                    Switch back to Normal view.

back to the top

Using the Hit Counter on the Page
 Type You are visitor followed by a space.</li> 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:  On the Insert menu, click Web Component.</li> In the Component Type list, click Advanced Controls.</li> In the Choose a control list, click HTML.</li> Click Finish.</li></ol> </li>  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. </li> Click OK to close the HTML Markup dialog box.</li></ol>

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 &quot;Installable Components&quot; 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

<div class="references_section">