Page_Init Event
This event will raise whenever page initialized and its first step in page life cycle. In this event all the controls in the page have been initialized and any theme or skin properties will be applied. This Page_Init event can be used to read or initialize control properties.
Declaration of Page_init
Generally we will use page_init event like as shown below
protected void Page_Init(object sender, EventArgs e){// Your Code Here}
For example check this for page_init event change page themes dynamically in asp.net
Page_Load Event
This event occurs only after Page_Init event and this event also will raise for every postback operation and in this stage all control properties are loaded with information recovered from view state and control state.
Declaration of Page_Load Event
Generally we will use page_load event like as shown below
protected void Page_Load(object sender, EventArgs e){// Your Code Here}If you want to check it in complete example you need to write the code in your aspx page like as shown below
C# Code
using System;public partial class BindDropdowninGridview : System.Web.UI.Page{protected void Page_Init(object sender, EventArgs e){Response.Write(“Init Event”);}protected void Page_Load(object sender, EventArgs e){Response.Write(“Page Load Event”);}}
VB.NET Code
Partial Class VBCodeInherits System.Web.UI.PageProtected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)Response.Write(“Init Event”)End SubProtected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)Response.Write(“Page Load Event”)End SubEnd Class
Page_Init - In page life cycle, this event fired when all the controls are initialized and at this stage initialize each control's properties.Page_Load - 1.In page life cycle , at this event all values are restored. 2.Most code checks the value of IsPostBack to avoid unnecessarily resetting state. 3.You may also call Validate and check the value of IsValid in this method. 4. You can also create dynamic controls in this method. the value assigned to each control is set.
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. This event occurs only when all the objects on the page have been created and are available for use
Page_init Page_init Event is First occur when a asp.net page is executed.This is where you perform any initialization steps that you need to set up or create instances of sever controls. You cant’s access controls in this event because there is no guarantee that they have been created yet. Controls are created during this, and you can control whether your attempt to use these objects will be denied by the server processing your request. The Page_Init event first 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 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.
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.