Determine which control fired in page_init

C

cheung

Hello,

Simple question. How can I determine which control fired event in the
Page_Init or Page_Load event handler?

I saw some post in the past with the similar question. One of the
recommendations was to use the sender argument. The questions is how? In my
case it contains the form itself and I cannot find how I can retrieve the
command name or any other information I need from it?

Another way is to add a generic handler for all these controls.

But I cann't find any sample code for both solution...

Any help is really appreciated

Cheung
 
M

Marina

Using the sender argument wouldn't help in Page_Load, since I think that
should just give you the page object.

A generic handler is also not recommended, as that would make your code hard
to read and confusing.

What is it you are trying to do? The actual recommendation is to make your
page_load code not be dependent on what event just fired. Event dependent
code should be place in the event handler for the control (button, etc), and
code that needs to fire every time in page_load.
 
J

Justin Bartels

This is probably not the best way of accomplishing what
you are trying to do, but Request.Form("__EVENTTARGET")
may get you what you are looking for.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top