The Button_Command event (VB.net) : Events « ASP.net Controls « ASP.NET Tutorial






<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    Protected Sub Button_Command(ByVal sender As Object, _
      ByVal e As System.Web.UI.WebControls.CommandEventArgs)

        Select Case e.CommandName
            Case "DoSomething1"
                Response.Write("Button 1 was selected")
            Case "DoSomething2"
                Response.Write("Button 2 was selected")
        End Select

    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Buttons</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button ID="Button1" 
                    Runat="server" 
                    Text="Button 1" 
                    OnCommand="Button_Command" 
                    CommandName="DoSomething1" />
        <asp:Button ID="Button2" 
                    Runat="server" 
                    Text="Button 2" 
                    OnCommand="Button_Command" 
                    CommandName="DoSomething2"/>
    </div>
    </form>
</body>
</html>








3.41.Events
3.41.1.Get event dispacher from event argument
3.41.2.The Button_Command event (VB.net)
3.41.3.The Button_Command event (C#)
3.41.4.Two types of events for the button (C#)
3.41.5.Two types of events for the button (VB)
3.41.6.EventHandler