Determine which control fired in page_init

Discussion in 'ASP .Net' started by cheung, Oct 20, 2003.

  1. cheung

    cheung Guest

    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
    cheung, Oct 20, 2003
    #1
    1. Advertising

  2. cheung

    Marina Guest

    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.

    "cheung" <> wrote in message
    news:...
    > 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
    Marina, Oct 20, 2003
    #2
    1. Advertising

  3. 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.

    >-----Original Message-----
    >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
    >.
    >
    Justin Bartels, Oct 20, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeff User
    Replies:
    6
    Views:
    4,721
    Jeff User
    Nov 28, 2005
  2. Replies:
    2
    Views:
    455
    Mark Rae
    Jun 19, 2006
  3. 1388-2/HB

    Page_Init and Control Events

    1388-2/HB, Dec 18, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    707
    bruce barker
    Dec 19, 2006
  4. =?Utf-8?B?YmVycnkubW9yZ2Fu?=

    HOWTO determine in content page page_load if masterpage fired post

    =?Utf-8?B?YmVycnkubW9yZ2Fu?=, Apr 17, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    459
    =?Utf-8?B?YmVycnkubW9yZ2Fu?=
    Apr 17, 2007
  5. milop
    Replies:
    6
    Views:
    565
    Andrew Raastad
    Apr 3, 2009
Loading...

Share This Page