473,473 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Check which button is clicked

Hi.
I have a ToolBar with a couple of ToolBarButtons. On postback after
clicking on of the buttons Page_Load is called first then the
ToolBarButton's click event is called. Is there anyway for me to check in
Page_Load which of the buttons have been clicked?

Thanks,
Shawn
Nov 19 '05 #1
4 1882
Is there any way to scan throught the ToolBar collection an object of type
Button and then by its index value identify that clicked button?

"Shawn" wrote:
Hi.
I have a ToolBar with a couple of ToolBarButtons. On postback after
clicking on of the buttons Page_Load is called first then the
ToolBarButton's click event is called. Is there anyway for me to check in
Page_Load which of the buttons have been clicked?

Thanks,
Shawn

Nov 19 '05 #2
Write an Event Handler for the ToolBarButton's click event. It isn't
necessary to use the Page_Load Sub to do all the work in your Page. In fact,
it isn't necessarily a good idea to do anything in particular in that Sub.
The Sub is for the purpose of executing processes that must run when the
Page loads. There are plenty of other events and methods for doing things in
a Page. See:

http://msdn.microsoft.com/library/de...nLifecycle.asp

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"Shawn" <bo********@hotmail.com> wrote in message
news:uQ*************@TK2MSFTNGP12.phx.gbl...
Hi.
I have a ToolBar with a couple of ToolBarButtons. On postback after
clicking on of the buttons Page_Load is called first then the
ToolBarButton's click event is called. Is there anyway for me to check in
Page_Load which of the buttons have been clicked?

Thanks,
Shawn

Nov 19 '05 #3
Kevin,
In general I don't do any particular work in page_load, but in this case I
have no choice. I'm adding checkboxes dynamically to my page and in order
to display them after a postback I have to re-create all of them. As far as
I know I have to do this in page_load. I tried doing it in
toolbar_save_ButtonClick(), but the checkboxes' state were no longer
available in ViewState. The reason why I want to know -in page_load- which
button was clicked, is because re-creation of the checkboxes is dependent on
which button is clicked, and since I can't re-create them in the buttons
click event I have to know this in page_load.

Shawn
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
Write an Event Handler for the ToolBarButton's click event. It isn't
necessary to use the Page_Load Sub to do all the work in your Page. In fact, it isn't necessarily a good idea to do anything in particular in that Sub.
The Sub is for the purpose of executing processes that must run when the
Page loads. There are plenty of other events and methods for doing things in a Page. See:

http://msdn.microsoft.com/library/de...nLifecycle.asp
--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Neither a follower nor a lender be.

"Shawn" <bo********@hotmail.com> wrote in message
news:uQ*************@TK2MSFTNGP12.phx.gbl...
Hi.
I have a ToolBar with a couple of ToolBarButtons. On postback after
clicking on of the buttons Page_Load is called first then the
ToolBarButton's click event is called. Is there anyway for me to check in Page_Load which of the buttons have been clicked?

Thanks,
Shawn


Nov 19 '05 #4
You can check the hidden "__EVENTTARGET" form field in the Request.Form
Collection, assuming that you have assigned a handler to the button's Click
event. This will contain the client-side ID of the Control that raised the
event.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"Shawn" <bo********@hotmail.com> wrote in message
news:ub****************@tk2msftngp13.phx.gbl...
Kevin,
In general I don't do any particular work in page_load, but in this case I
have no choice. I'm adding checkboxes dynamically to my page and in order
to display them after a postback I have to re-create all of them. As far
as
I know I have to do this in page_load. I tried doing it in
toolbar_save_ButtonClick(), but the checkboxes' state were no longer
available in ViewState. The reason why I want to know -in page_load-
which
button was clicked, is because re-creation of the checkboxes is dependent
on
which button is clicked, and since I can't re-create them in the buttons
click event I have to know this in page_load.

Shawn
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
Write an Event Handler for the ToolBarButton's click event. It isn't
necessary to use the Page_Load Sub to do all the work in your Page. In

fact,
it isn't necessarily a good idea to do anything in particular in that
Sub.
The Sub is for the purpose of executing processes that must run when the
Page loads. There are plenty of other events and methods for doing things

in
a Page. See:

http://msdn.microsoft.com/library/de...nLifecycle.asp

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Neither a follower nor a lender be.

"Shawn" <bo********@hotmail.com> wrote in message
news:uQ*************@TK2MSFTNGP12.phx.gbl...
> Hi.
> I have a ToolBar with a couple of ToolBarButtons. On postback after
> clicking on of the buttons Page_Load is called first then the
> ToolBarButton's click event is called. Is there anyway for me to check in > Page_Load which of the buttons have been clicked?
>
> Thanks,
> Shawn
>
>



Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Krista | last post by:
Hi, this is my problem. I have two php files such as a.php, b.php a.php : <?php require("b.php"); if($_GET == "") { MainFrame(); } else if ($_GET == "Receiving")
0
by: Sandra | last post by:
I have a form with a list view control that has the checkboxes property set to true. This provides checkboxes as the first column in the listview. When a listviewitem is checked another form is...
4
by: Jared | last post by:
Radio Button or Check Box and Event Procedures I need to insert either radio buttons or check boxes onto my form. I'm not sure which to use, or if there are other options. I am using the buttons...
7
by: Shaldaman | last post by:
Hi Is there a property in MS Access for the following: 1) For a Command Button on a form, is there a property that can be used to determine if it has been clicked? eg: Me!button7.Clicked - I...
0
by: | last post by:
hi, selected items in check box disappears when submit button is clicked on aspx page. check box is pasted on .ascx page and which is pasted on aspx page any ideals cheers sam
0
by: Alex | last post by:
Hi there! I got some LinkButtons, all declared as "Public Withevents buttonName as LinkButton". I know the button names and IDs. Now I want to check in the Page_Load Method which button was...
11
by: bill | last post by:
I dynamically create buttons and associate them with an event using AddHandler. I want all the button events to fire at one time, when the page is posted, instead of when each button is clicked....
1
by: JHawk24821 | last post by:
I am building a simple card matching game where the user picks two buttons on a form out of a group of buttons in an attempt to find a match. I have already taken care of the randomization needed...
2
by: damonjulian | last post by:
hi ,i created 3 buttons such that if button1 is clicked it will disable button2 ,and clicking button3 will restore state of button2 to normal, to my dismay i find that button2 still responds 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
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.