Mega Code Archive

 
Categories / ASP.Net Tutorial / ASP Net Controls
 

The Button_Command event (VB net)

<%@ 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>