Detect which button was clicked?

G

Guest

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

Thanks, Dave
 
K

Kevin Spencer

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 said:
If you have multiple buttons on a web form, how can you detect which
control was clicked in the Page_Load event?
 
G

Guest

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
 
G

Guest

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top