Detect which button was clicked?

Discussion in 'ASP .Net' started by =?Utf-8?B?RGF2ZQ==?=, Feb 26, 2004.

  1. If you have multiple buttons on a web form, how can you detect which control was clicked in the Page_Load event

    Thanks, Dave
    =?Utf-8?B?RGF2ZQ==?=, Feb 26, 2004
    #1
    1. Advertising

  2. You can detect which control was clicked by writing an event handler for it.

    --
    HTH,
    Kevin Spencer
    ..Net Developer
    Microsoft MVP
    Big things are made up
    of lots of little things.

    "Dave" <> wrote in message
    news:...
    > If you have multiple buttons on a web form, how can you detect which

    control was clicked in the Page_Load event?
    >
    > Thanks, Dave
    Kevin Spencer, Feb 26, 2004
    #2
    1. Advertising

  3. I don't think there's a way ASP.NET tells which button was clicked in the Page_Load. Although I've seen people mention a server variable?? EVENT_TARGET?? or something to that effect that supposed to tell you which button click is being processed. But the only way I've been able to do it is thru setting a hidden variable on the client that I set using javascript when the asp.net server side button is clicked. Then it just like old asp where you access the hidden text using Request.Form["myhiddentextid"]

    Why do you want to do this anyway
    ASP.NET does allow you to designate and handle events for server side buttons individually

    Suresh

    ----- Dave wrote: ----

    If you have multiple buttons on a web form, how can you detect which control was clicked in the Page_Load event

    Thanks, Dave
    =?Utf-8?B?U3VyZXNo?=, Feb 26, 2004
    #3
  4. Yes..

    This is what I was referring to when I sai
    >Why do you want to do this anyway
    >ASP.NET does allow you to designate and handle events for server side buttons individually


    I may have misunderstood you when you said
    >If you have multiple buttons on a web form, how can you detect which control was clicked in the Page_Load event


    There isn't way to do this in the Page_Load event. The button click is a seperate event and has to be handled outside of the Page_Load event

    Suresh

    ----- Dave wrote: ----

    Thanks, I think you can. This is what I found in regards to Kevin's response

    http://msdn.microsoft.com/library/d...l/vbtskrespondingtobuttonwebcontrolevents.asp
    =?Utf-8?B?U3VyZXNo?=, Feb 26, 2004
    #4
    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. Replies:
    0
    Views:
    383
  2. bthumber
    Replies:
    4
    Views:
    462
    bthumber
    Jun 25, 2010
  3. Yossi

    Which button was clicked and on which row?

    Yossi, Nov 17, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    730
    Yossi
    Nov 17, 2006
  4. Jim Mitchell
    Replies:
    0
    Views:
    190
    Jim Mitchell
    Jul 12, 2003
  5. Quinn
    Replies:
    5
    Views:
    306
    Griff
    Jul 8, 2005
Loading...

Share This Page