How to: Determine which Web Server Control Raised an Event

When an event handler is called, you can determine which control caused the event.

To determine which control caused the event

  1. In the event handler, declare a variable whose type matches the control that raised the event.

  2. Assign the sender argument of the event handler to the variable, casting it to the appropriate type.

    The following example shows the handler for a Button-control click event that is called by several different buttons. The handler displays information about which button was clicked.

    No code example is currently available or this language may not be supported.

See Also

Community Additions