Alex Rivera | Logout

Page_Init vs OnInit

Asked 2009-08-10T16:03:41.130
28

Between handling the Page_Init event or overriding the OnInit method of a Page, which one is better to use? Thanks.

Edit
Report

1 Answer

12

Overriding the base type's method is preferable as a virtual call is simpler and cleaner than creating a delegate attaching an event to a method group.

Also, relying on AutoEventWireup being set to true means that you are introducing overhead into the parsing of your page code as ASP.NET will have to create any delegates for you at execution-time.

answered 2009-08-10T16:15:32.027

Your Answer