Check if button is already clicked C#

May 7 2014 3:16 PM
I'm building a web application i Visual Studio using C#.
 
I need to check if it is the first time a button is clicked. If it is the first time I want to pick variables from one place. If it is not the first time I want to pick variable from another place. 
 
I tried using a class Click 
 
namespace myProject
{
public class Click
{
public int buttonclick = 0;
}
 
In button click:
 
Click.buttonclick++;
if (Click.buttonclick == 1)
{
MessageBox.Show("First click");
}
else
MessageBox.Show("Other clicks"); 
 
 
This code works the first time the web form is visited. If I go to another page and then return to this page the variable does not resets to zero. I need the variable to reset to zero every time page is visited. Is there another solution for this?

Answers (2)