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

Check which button is clicked

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.