By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,246 Members | 1,480 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,246 IT Pros & Developers. It's quick & easy.

Detect which button was clicked?

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

Thanks, Dave
Nov 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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" <an*******@discussions.microsoft.com> wrote in message
news:37**********************************@microsof t.com...
If you have multiple buttons on a web form, how can you detect which control was clicked in the Page_Load event?
Thanks, Dave

Nov 18 '05 #2

P: n/a
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
Nov 18 '05 #3

P: n/a
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 saidIf 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/de...trolevents.asp
Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.