Determine which control fired in page_init

  • Thread starter Thread starter cheung
  • Start date Start date
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
 
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.
 
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.
 
Back
Top