<script runat="server">
protected void Button_Click(object sender, EventArgs e)
{
Button btn = (Button)sender;
btn.Text = (Int32.Parse(btn.Text) + 1).ToString();
}
</script>
This is a demonstration of button counter. every time we click the button it is incremented.<br />
First Counter:
<asp:Button
id="Button1"
Text="0"
OnClick="Button_Click"
Runat="server" />
<br /><br />
Second Counter:
<asp:Button
id="Button2"
Text="0"
OnClick="Button_Click"
Runat="server" />