Jun 18, 2011, 7:57 AM
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:
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