OnCommand, for asp:linkbutton : Link Button « Asp Control « ASP.Net

Home
ASP.Net
1.ADO.net Database
2.Ajax
3.Asp Control
4.Collections
5.Components
6.Data Binding
7.Development
8.File Directory
9.HTML Control
10.Language Basics
11.Login Security
12.Mobile Control
13.Network
14.Page
15.Request
16.Response
17.Server
18.Session Cookie
19.Sitemap
20.Theme Style
21.User Control and Master Page
22.Validation by Control
23.Validation by Function
24.WebPart
25.WPF
26.XML
ASP.Net » Asp Control » Link Button 
OnCommand, for asp:linkbutton

<%@ 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 SubmitBtn1_Click(Sender As Object, E As EventArgs)
    lblMessage.Text = "You pressed the alone 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>Link 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"
/>
<BR><BR>
<asp:LinkButton 
    id="butAlone"
    text="Alone Button"
    OnClick="SubmitBtn1_Click" 
    runat="server"
/>
<BR><BR>
<asp:LinkButton 
    id="butAdd"
    text="Add Record"
    CommandName="Add"
    CommandArgument="None"
    OnCommand="SubmitBtn2_Click" 
    runat="server"
/>
<asp:LinkButton 
    id="butEdit"
    text="Edit Record"
    CommandName="Edit"
    CommandArgument="None"
    OnCommand="SubmitBtn2_Click" 
    runat="server"
/>
<asp:LinkButton 
    id="butSortA"
    text="Sort A-Z"
    CommandName="Sort"
    CommandArgument="A"
    OnCommand="SubmitBtn2_Click" 
    runat="server"
/>
<asp:LinkButton 
    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
1.asp:linkbutton: command name and arguments
2.asp:link button event to change the label text
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.