int i=0;
public void Button_Click(object sender EventArgs e)
{
Textbox.Attributes.Add("readonly", "true");
i=Convert.ToInt32(Textbox.value);
if(i<=0)
Button.diabled=true;
i--;
Textbox.value=i.toString();
}
In this program we disable the textbox in the button click event so the user cannot change the data in the textbox.
and we are retrieving the value in the textbox and checking if it is less than or equal to 0 the button is also get disabled otherwise we decrement the value in the textbox by 1 and updating it so that we can use the updated value in the next button click event.