click counter

  1. #1

    click counter

    hello

    i have a simple page with button and label, and i want to count button clicks and show thic counter in label, this is my code:
     
    int a;
    protected void Page_Load(object sender, EventArgs e)
    {
     
    if (!X.IsAjaxRequest)
    {
    a = 1;
    Label1.Text = a.ToString();
    }
    }
     
    protected void clickb(object sender, DirectEventArgs e)
    {
    a = Convert.ToInt16(Label1.Text) + 1;
     
    Label1.Text = a.ToString();
    }
    the problem is that afer each click value is set to 2, what is wrong here
  2. #2
    Hi,

    I can suggest a few options:

    1. Store the count value in a HiddenField. The count will then be submitted when you submit the form.

    2. Store the count value in a Session or Application level variable.

    3. Store the count value in a Database.

    4. other. Some other form of persistant storage of the count value.

    Hope this helps.
    Geoffrey McGill
    Founder

Similar Threads

  1. Replies: 1
    Last Post: Mar 13, 2012, 8:37 AM
  2. Replies: 2
    Last Post: Oct 22, 2010, 11:04 AM
  3. Text counter for a textarea
    By jmilton in forum 1.x Help
    Replies: 1
    Last Post: Oct 11, 2010, 5:06 PM
  4. Fire cell click on row double-click
    By RPIRES in forum 1.x Help
    Replies: 1
    Last Post: Jul 01, 2010, 8:20 PM
  5. [CLOSED] row click
    By speedstepmem2 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 30, 2009, 8:44 AM

Posting Permissions