468,283 Members | 1,798 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,283 developers. It's quick & easy.

Detect which button was clicked?

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
3 4984
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
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
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.

Similar topics

3 posts views Thread by Lord2702 | last post: by
8 posts views Thread by thomasamillergoogle | last post: by
reply views Thread by paulsanna | last post: by
2 posts views Thread by John | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.