Count Number of Click in C#

protected void Button_Click(object sender, EventArgs e)
    {
        Button btn = (Button)sender;
        btn.Text = (Int32.Parse(btn.Text) + 1).ToString();

    }

First ScreenShot:

ButtonClick.png

Second ScreenShot:

CreateButtonInCSharp.png

Third ScreenShot:

CreateButtoninDotNet.png
<
div>
    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" />       

    </div
>

 

Ebook Download
View all
Learn
View all