Abhijeet
Abhijeet

Reputation: 13856

Practical use of sender & EventArgs in Page_Load

I am on the verge migrating all my asp.net WebForms skills to asp.net mvc. So far, I never felt a need to use EventArgs and sender argument, passed to Page_Load.

Can you please point me a couple of scenario, when you leverage theses parameters?

Upvotes: 3

Views: 2854

Answers (2)

Guffa
Guffa

Reputation: 700342

All event handlers follow the same pattern, i.e. they have a sender parameter and an arguments parameter.

The event handler for the Load event very rarely make use of either, because you almost (?) always have one event handler for each form or control (so you already know which object sent the event), and there is no specific data send in the arguments parameter.

You use the sender parameter when you use the same handler for more than one event, to find out where the event came from. You use the arguments parameter for some event where there is some specific data sent to the event handler.

Upvotes: 2

Alberto León
Alberto León

Reputation: 2921

You never will use EventArgs or Sender, never will use Page_Load method

Because MVC manage calls as Actions

EventArgs result of parse a POST

So if you need any thing in eventargs in your old code, in the new you should past this as formcollection

Upvotes: 0

Related Questions