Button action Command and Parameter (VB.net)
<%@ Page Language=VB Debug=true %>
<script runat=server>
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
lblMessage.Text = "Press a button!"
End Sub
Sub SubmitBtn2_Click(Sender As Object, E As CommandEventArgs)
lblMessage.Text = "The button you clicked: " _
& e.CommandName _
& ", has the following arguement: " _
& e.CommandArgument & "."
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>Button Controls Sample Page</TITLE>
</HEAD>
<BODY>
<form runat="server">
<Font Face="Tahoma" Size="+1">
<asp:Label
id="lblMessage"
Text="Press a button!"
runat="server"
/>
<asp:Button
id="butAdd"
text="Add Record"
CommandName="Add"
CommandArgument="None"
OnCommand="SubmitBtn2_Click"
runat="server"
/>
<asp:Button
id="butEdit"
text="Edit Record"
CommandName="Edit"
CommandArgument="None"
OnCommand="SubmitBtn2_Click"
runat="server"
/>
<asp:Button
id="butSortA"
text="Sort A-Z"
CommandName="Sort"
CommandArgument="A"
OnCommand="SubmitBtn2_Click"
runat="server"
/>
<asp:Button
id="butSortD"
text="Sort Z-A"
CommandName="Sort"
CommandArgument="D"
OnCommand="SubmitBtn2_Click"
runat="server"
/>
</Font>
</Form>
</BODY>
</HTML>
Related examples in the same category