Last post Jul 13, 2017 03:20 AM by Eric Du
Jul 12, 2017 07:06 PM|aspfun|LINK
What is difference between page_load and page_init?
When a page open, I need to add codes to load something.
Where to add code, in page_load or page_init?
Jul 12, 2017 07:11 PM|ryanbesko|LINK
Plenty of answers already exist all over the web. The above one is directly from MS.
Also, "load something" isn't that helpful. Are you loading a control, accessing data, what?
Jul 13, 2017 03:20 AM|Eric Du|LINK
According to your description, as far as I know, these two events are in the asp.net page lifecycle. Page_init is executed before Page_load.
Raised after all controls have been initialized and any skin settings have been applied. The Init event of individual controls occurs before the Init event of the page.
Use this event to read or initialize control properties.
The Page object calls the OnLoad method on the Page object, and then recursively does the same for each child control until the page and all controls are loaded. The Load event of individual controls occurs after the Load event of the page.
Use the OnLoad event method to set properties in controls and to establish database connections.
Here are some tutorials about these two events difference, please check:
ASP.NET Page Life Cycle Overview:
Asp.net Difference between Page_Load and Page_Init in C#, VB.Net: