Qasim Qasim - 1 month ago 8
ASP.NET (C#) Question

What is the use of "object sender" and "EventArgs e" parameters?

In case of

and other page events, what is the use of these
(object sender, EventArgs e)

Examples would be more helpful.


EventArgs e is a parameter called e that contains the event data, see the EventArgs MSDN page for more information.

Object Sender is a parameter called Sender that contains a reference to the control/object that raised the event.

Event Arg Class:


protected void btn_Click (object sender, EventArgs e){
   Button btn = sender as Button;
   btn.Text = "clicked!";

Edit: When Button is clicked, the btn_Click event handler will be fired. The "object sender" portion will be a reference to the button which was clicked