Button event Handler (C#) : Button « Asp Control « ASP.Net






Button event Handler (C#)

<%@ Page Language="C#" Debug="true"%>
<script runat="server">

    void ClickHandler(object sender, EventArgs e)
    {
        if (ExtraInfoBox.Checked)
        {
            Message.Text = "You will hear from us shortly";
        }
        else
        {
            Message.Text = "You will not receive any further information from us";
        }
    }

</script>
<html>
<head>
</head>
<body>
    <form runat="server">
        <asp:CheckBox id="ExtraInfoBox" runat="server" Text="Click here to receive extra information"></asp:CheckBox>
        <br />
        <br />
        <asp:Button id="Button1" onclick="ClickHandler" runat="server" Text="Click here to submit"></asp:Button>
        <br />
        <br />
        <asp:Label id="Message" runat="server"></asp:Label>
    </form>
</body>
</html>

           
       








Related examples in the same category

1.Event in code behind file (VB.net)
2.asp:button: command name and arguments (VB.net)
3.Event driven page (VB.net)
4.Set Button text (VB.net)
5.asp:button event to change the label text (VB.net)
6.Button action Command and Parameter (VB.net)
7.Add action listener to a server Button (VB.net)
8.asp button postbackurl (C#)
9.asp button on client click (C#)
10.Button counter: click and change button label (C#)
11.Add action listener to asp Button by delegate (C#)
12.Read input and do the calculation in Button action listener (C#)
13.onmouseover and onmouseout events
14.OnClientClick event
15.CausesValidation="False"