VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Use Page Counter component to count how many times the current page was hit

by Yuening Dai (30 Submissions)
Category: Active Server Pages
Compatability: ASP (Active Server Pages)
Difficulty: Unknown Difficulty
Originally Published: Fri 13th October 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Use Page Counter component to count how many times the current page was hit

Rate Use Page Counter component to count how many times the current page was hit



<HTML>
<HEAD>
<TITLE>ASP 2.0 Demo - The Page Counter Component</TITLE>
</HEAD>
<BODY>
<H2>ASP 2.0 Demo -The Page Counter Component</H2>
<HR>
This sample show how to use <B>Page Counter</B> component to count how many times the current page was hit. This component is implemented in file <B>PAGECNT.DLL</B>. Make sure you have it on your server and installed properly. You can use the Personal Web Server to test this ASP page.
<P>
<font color=blue>How to: Click the Refresh or Reload menu button to see the result ! </font>
<HR>
<P>
 <%
  Dim objPC
  Dim lngHitCount
  On Error Resume Next
  Set objPC=Server.CreateObject("IISSample.PageCounter")
  If IsObject(objPC)=False Then
    Response.Write "The Page Counter component object can not be created at this time. "
    Response.Write "Either you do not have this component on the server machine or it "
    Response.Write "is not installed properly."
    Response.Write "You may try to fix this problem by installing IIS Resource Kit."
  Else
    Response.Write "The Page Counter component object is created successfully !<P>"
    lngHitCount=objPC.PageHit()
    Response.Write("Number of times (reset one) this page was hit - ")   
    Response.Write cstr(lngHitCount)
    Response.Write("<BR>")
    If ((lngHitCount Mod 10)=0) Then
       Response.Write("<font color=red><P>You hit the lucky number.</font><BR>")
       If (lngHitCount>=100) Then    ' Reset count.
 objPC.Reset
         Response.Write("The page counter was reset every time it reaches 100 !")
       End If
    End If
  End If
  %>
<P>
</BODY>
</HTML>


Download this snippet    Add to My Saved Code

Use Page Counter component to count how many times the current page was hit Comments

No comments have been posted about Use Page Counter component to count how many times the current page was hit. Why not be the first to post a comment about Use Page Counter component to count how many times the current page was hit.

Post your comment

Subject:
Message:
0/1000 characters