What is the difference between the Page_Init and Page_Load events?

 Posted by deccansoft on 10/30/2010 | Category: ASP.NET Interview questions | Views: 17540


Page_Init
The Page_Init event is the first to occur when an ASP.NET page is executed. This is where you perform any initialization steps that you need to set up or create instances of server controls. You can't access controls in this event because there is no guarantee that they have been created yet. Controls are created during this event, and you can control whether your attempt to use these objects will be denied by the server processing your request.
The Page_Init event fires only the first time the page is loaded. When you postback to any page, the Page_Init event doesn't fire.
The Page_Load event fires each time the page loads, postback or not.

Page_Load
This event occurs only when all the objects on the page have been created and are available for use.


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Posted by: Kundlashyam on: 10/18/2014 | Points: 10
Who says, the page_Init event fires only the first time. If that was the case why one would use session variables to manage the state of the page. Please do not spread the wrong information. The page_Init fires even on the post backs. Try your self.
Posted by: Vinodkpasi on: 11/6/2017 | Points: 10
Page_Init fires always

Login to post response