473,396 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 5200
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Quinn | last post by:
When users clicked a unkown mime type link such as Zip on my website, a "Save/Open/Cancel" dialog box pops up. Is there a way to detect which button users clicked by using ASP? actually I only what...
2
by: Bob Hynes | last post by:
Hi All, When a user(s) click on the 'Apply Filter' toolbar button I want to run some code before the 'apply filter' kicks off. That code is to check to be sure that the user has selected a value...
1
by: jdph40 | last post by:
I am using Access 2002. I downloaded the forms sample database FrmSmp97.mdb from Microsoft and used the following code in the timer event of a hidden form in order to close a database if no...
3
by: Lord2702 | last post by:
Sat. Oct. 30, 2004 3:25 PM PT I want to detect, if user has close the browser, (after logging to my site), that user has closed the browser. How to achieve it ? I want to know this close action...
8
by: thomasamillergoogle | last post by:
I am trying to detect what asp.net button was clicked duing the page_load event. I have two asp.net buttons on my page. What is the easiest way to detect this?
5
by: BenCoo | last post by:
Hello everyone, I've a form with a groupbox witch contain 4 buttons. I searching for a solutions to detect when I click on one of the buttons returning a reference to the button thas has been...
2
by: tarun.kataria | last post by:
Hi all, In my ASP.NET application, I am trying to detect in a javascript function, which is triggered by the event onbeforeunload, that if the window is getting closed beacuse its a post back or...
0
by: paulsanna | last post by:
Hi there, I have 2 buttons on the source page that would submit the form to the target. The target page page would do something different with the results based on which button was clicked. I am...
2
by: John | last post by:
Hi, I would like to create an eventhandles that handles several different buttons. How can I detect which button was clicked on ? I know it something with the sender ... something like
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.