Making Your Own Web Counter

Step 1.    Create Global.asax file in your application.

Step 2.    In Application_Start Function write the code below

        Application["Hits"] = 0;


 

Step 3.    In Global.asax file's Session_Start function write the code below

        Application.Lock();

        Application["Hits"] = Convert.ToInt32((Application["Hits"].ToString()))+1;

        Application.UnLock();

Step 4.    Now Where ever you want to show the user counter.

  1. Insert a label at that place where you want to show the counter.

    <asp:Label
ID="Lblcounter"
runat="server"
Text=""></asp:Label>


 

  1. IN Page_Load event Write the code below.

        Lblcounter.Text = Application["Hits"].ToString();

Search This Blog

Link Within Related Posts Plugin for WordPress, Blogger...