protected void page_load(object sender,EventArgs e)
why we use object sender and eventargs e?
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
CrishRank #1,487 · 1.1K reputationPosted Apr 13, 2011, 4:13 AM EDT
This solve the problem page load
it is a standard in .NET that event handlers have this signature, usually declared by some delegate types for example EventHandler. sender references the object that raised the particular event, for example with Button's Click it would let you reference the Button control via sender argument.
EventArgs represents the data related to that event, and can be used to pass parameters, state information whatsoever to the event handler for the handling code to decide what to do. In this case it is just EventArgs which represents empty event arguments but for example if you have ImageButton's Click handler, you'll note that it's event arguments provide you access to the X and Y coordinates. In other words, Event args can be represented by more specific classes with event related data, depending on the control
Ankit NandekarRank #703 · 3.4K reputationPosted Apr 11, 2011, 10:25 PM EDT
you can use sender like
CheckBox chk=(sender) CheckBox;
The EventArgs parameter contains the additional information about the event.
Soft CornerRank #1,221 · 1.5K reputationPosted Apr 11, 2011, 10:58 PM EDT
When an event is fired it will send a reference of the object that the event is fired from in the sender parameter and any additional information in the e parameter. e is usually of type EventArgs which does not provide usefull information but most classes derive a new class from EventArgs, add additional properties to them and use them as the second parameter of their events. This way the user will be notified of any additional information when handling those events.
Also, If you want to call the page_load function in another function, it depends on whether you are using sender and e in your event handler or not, if you don't you can simply pass nulls as both parameters i.e. Page_Load(null, null)