In case of Page_Load, Init and other page events, what is the use of these (object sender, EventArgs e) parameters?
Page_Load
Init
(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.
EventArgs e
Object Sender is a parameter called Sender that contains a reference to the control/object that raised the event.
Object Sender
Event Arg Class: http://msdn.microsoft.com/en-us/library/system.eventargs.aspx
Example:
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
1.4m articles
1.4m replys
5 comments
57.0k users