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
-
In the event handler, declare a variable whose type matches the control that raised the event.
-
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.
Show: