Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Web Controls (http://www.velocityreviews.com/forums/f63-asp-net-web-controls.html)
-   -   Find the source of an event (http://www.velocityreviews.com/forums/t777370-find-the-source-of-an-event.html)

Vi 12-10-2005 08:50 PM

Find the source of an event
 
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

Phillip Williams 12-10-2005 09:12 PM

RE: Find the source of an event
 
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



All times are GMT. The time now is 01:40 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.