asp:linkbutton: command name and arguments : Link Button « Asp Control « ASP.Net






asp:linkbutton: command name and arguments

<%@ Page Language=VB Debug=true %>
<script runat=server>
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)

End Sub
Sub CommandButton_Click(Sender As Object, E As CommandEventArgs)
  lblButtonPressed.Text = "You pressed: " _
      & E.CommandName & "<BR>With this argument: " _
      & E.CommandArgument & "<BR>"
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>Creating a Basic LinkButton Control</TITLE>
</HEAD>
<form runat="server">
<asp:label 
    id="lblButtonPressed" 
    runat="server"
/>
<BR><BR>
<asp:linkbutton 
    id="lnkbutSortName"
    text="Sort By Name"
    oncommand="CommandButton_Click"
    commandname="Sort"
    commandargument="By Name"
    runat="server"
/>
<BR><BR>
<asp:linkbutton 
    id="lnkbutSortPrice"
    text="Sort By Price"
    oncommand="CommandButton_Click"
    commandname="Sort"
    commandargument="By Price"
    runat="server"
/>
<BR><BR>
<asp:linkbutton 
    id="lnkbutNewSearch"
    text="New Search"
    oncommand="CommandButton_Click"
    commandname="New Search"
    commandargument="None"
    runat="server"
/>
</form>
</BODY>
</HTML>
           
       








Related examples in the same category

1.OnCommand, for asp:linkbutton
2.asp:link button event to change the label text