Find the source of an event

Discussion in 'ASP .Net Web Controls' started by Vi, Dec 10, 2005.

  1. Vi

    Vi Guest

    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
     
    Vi, Dec 10, 2005
    #1
    1. Advertising

  2. 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
     
    Phillip Williams, Dec 10, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ~~~ .NET Ed ~~~
    Replies:
    1
    Views:
    4,223
    Cowboy \(Gregory A. Beamer\)
    Feb 26, 2005
  2. Marcus Leon
    Replies:
    5
    Views:
    610
    Marcus Leon
    Feb 3, 2005
  3. Wybo Dekker
    Replies:
    1
    Views:
    395
    Yukihiro Matsumoto
    Nov 15, 2005
  4. vdvorkin
    Replies:
    0
    Views:
    437
    vdvorkin
    Feb 10, 2011
  5. vdvorkin
    Replies:
    3
    Views:
    863
    vdvorkin
    Feb 14, 2011
Loading...

Share This Page