Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Find the source of an event

Reply
Thread Tools

Find the source of an event

 
 
Vi
Guest
Posts: n/a
 
      12-10-2005
Hi,
I'm trying to attach a code behind method to two different LinkButton
controls on my page.

How can I find out which of the controls fired up the event in the code
behind method that handles the event?

Thanks
 
Reply With Quote
 
 
 
 
Phillip Williams
Guest
Posts: n/a
 
      12-10-2005
The Commnad event passes a parameter of type CommandEventArgs that has a
value for the CommandName attribute of the LinkButton control, e.g.

<asp:LinkButton ID="LinkButton1" runat=server CommandName ="DeleteARecord"
OnCommand ="LinkButtons_Command"></asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat=server CommandName ="AddARecord"
OnCommand ="LinkButtons_Command" ></asp:LinkButton>

protected void LinkButtons_Command(object sender, CommandEventArgs e)
{
switch (e.CommandName)
{
case "DeleteARecord":
//add code to delete
break;
case "AddARecord":
//add code to add a record
break;
}
}
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com


"Vi" wrote:

> Hi,
> I'm trying to attach a code behind method to two different LinkButton
> controls on my page.
>
> How can I find out which of the controls fired up the event in the code
> behind method that handles the event?
>
> Thanks

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to exclude action of Find::Find::find in subdirectories withknown names? vdvorkin Perl Misc 3 02-14-2011 05:28 AM
How to exclude action of Find::Find::find in subdirectories withknown names? vdvorkin Perl Misc 0 02-10-2011 05:18 PM
Find.find does not find orphaned links? Wybo Dekker Ruby 1 11-15-2005 02:50 PM
Adding a web application project to source control (Visual Source Safe) ~~~ .NET Ed ~~~ ASP .Net 1 02-26-2005 02:20 PM
Data Recovery SOURCE CODE ( SOURCE CODES of Professional Data Recovery Software ) Author Tarun Tyagi Cisco 0 12-29-2004 05:03 PM



Advertisments