In this article I will show the loading process sequence of a Master Page that contains a Contents Page and that Contents Page has a User Control.
Step 1:
Create a website named "Loading_sequence".

Step 2:
- Add a Master Page named "MatserPage.master" within it by right-clicking on the website in "Solution Explorer" then choose "Add" -> "Add New Item".

- Create some events in the ".cs" file of the Master Page and add a "response.write()" method with unique text for monitoring the process of execution.
- protected void Page_PreInit(object sender, EventArgs e)
- {
- Response.Write("Master Page Pre Init event called <br/> ");
- }
- protected void Page_Init(object sender, EventArgs e)
- {
- Response.Write("Master Page Init event called <br/> ");
- }
- protected void Page_Load(object sender, EventArgs e)
- {
- Response.Write("Master Page Load event called <br/> ");
- }

Step 3:
- Add a Contents Page named "Default.aspx" within it by the right-clicking on the website in Solution Explorer then choose "Add" -> "Add New Item" and check the "Select master page" checkbox to attach the Master Page.

- Select the Master Page name that you want to attach.

- Create some events in the ".cs" file of the Contents Page and add a "response.write()" method with unique text by which we can monitor execution as written in the Master Page.
- protected void Page_PreInit(object sender, EventArgs e)
- {
- Response.Write("Content Page Pre Init event called <br/> ");
- }
- protected void Page_Init(object sender, EventArgs e)
- {
- Response.Write("Content Page Init event called <br/> ");
- }
- protected void Page_Load(object sender, EventArgs e)
- {
- Response.Write("Content Page Load event called <br/> ");
- }

Step 4:
- Add a Web User Control named "WebUserControl.aspx" within it by right-clicking on the website in Solution Explorer then choose "Add" -> "Add New Item".

- Create some events in the ".cs" file of the Web User Control and add a "response.write()" method with unique text for monitoring the execution as written in the Master Page and the Contents Page.
- protected void Page_PreInit(object sender, EventArgs e)
- {
- Response.Write("User Control Pre Init event called <br/> ");
- }
- protected void Page_Init(object sender, EventArgs e)
- {
- Response.Write("User Control Init event called <br/> ");
- }
- protected void Page_Load(object sender, EventArgs e)
- {
- Response.Write("User Control Load event called <br/> ");
- }

Step 5:
Add the Web User Control to the Contents Page then "Register Tag" and write the code to access the control by the "TagPrefix" and "TagName".

Step 6:
Run the website to see the output.


Dhanesh KumarPosted Aug 29, 2019, 1:41 AM
Nice one ........
Srinivas Rao BolisettiPosted Nov 20, 2016, 1:27 AM
When the master page pre init and user control pre init event will load.
AniPosted Mar 9, 2016, 6:30 AM
Thanks for sharing
ashish kansalPosted Dec 9, 2015, 3:14 AM
Nice article
Lalit RaghavPosted Jun 6, 2015, 11:38 AM
Thanks Sir
Upendra Pratap ShahiPosted Jun 1, 2015, 9:08 AM
nice..
Hamid KhanPosted Feb 23, 2015, 10:51 PM
Thanks
Rahul BansalPosted Jan 28, 2015, 10:37 PM
Thanks
Santosh YadavPosted Jan 28, 2015, 12:48 PM
great article
Satya RathorePosted Nov 9, 2014, 11:19 PM
Wonderful description given by rahul; For more description please see the below link; Click Here