Skip to main content

Page Life Cycle Between Content Page (ASPX Page) and User Control in ASP.Net

Here I would like to introduce the page life cycle between ASPX page and User Control. And it is very important that ASP.Net developers to be familiar with this.

We have an ASPX page that contains a User Control. 

I was trying to find the sequence of events between ASPX page and User Control. The following is the diagram that helps us to understand the sequence of events between ASPX page and User Control.

Consider the cycle below in a clockwise direction that starts from Preinit of the ASPX page and completes at the unload of the ASPX page.





The following are the outcomes of the diagram above:
  1. First Preinit of ASPX is called.
  2. The User Control does not have a Preinit event.
  3. The Unload of the Usercontrol is called before the Unload of the ASPX page.
Behavior of Master Page is like User Control
When I tried to find the sequence of events between a Master Page and ASPX Page I found the same sequence of events as I explained above.

We often get confused bhy the belief that a Master Page is also a Parent Page, but this is not true.

I was trying to find the sequence of events between a Master Page and an ASPX Page (and a User Control and an ASPX page),

Then I discovered that the sequence of events are the same in both cases.

For more details
Reason for Master Page to Behave like a Usercontrol in ASP.Net

MSDN link
Events in ASP.NET Master and Content Page

Comments

Contact Form

Name

Email *

Message *

Popular posts from this blog

Exporting DataTable to Excel in C# Using Interop

Introduction I would like to share a utility that can be used to export a datatable to Excel file using C#. We have various approaches to perform this activity. In ASP.NET we can do this by changing the Content type to xls but in C# .Net we might have various other approaches. Through this article we will learn how to export a data table to Excel using Interop. Code and Steps Here in this application we will use a Sample datatable and then learn how to export data to an Excel file. We will learn the following things in this article: Creating Excel file using C# Writing data to cells Formatting data to cells Working with Excel range 1. Adding References First we need to add a reference for Microsoft.office.interop.Excel as in the following: 2. Adding sample data table to the code Use the following code to add the sample data table:     static   DataTable  GetTable()     {       ...

Adding CheckBox Column in DataGridView in C# Window Forms

Introduction  I would like to share three ways to add a checkbox to a DataGridView in a C# Windows Forms application. We will learn the following three ways to add a checkbox to a DataGridView: Binding a List to a DataGridView having a bool property Binding a datatable to a DataGridView having a bool column Adding a checkbox column (DataGridViewCheckBoxColumn) to the DataGridView. Procedure 1. Binding a List to a DataGridView having a bool property. Add the following class to the project: public   class  Emp   {       public   bool  isMarried {  get ;  set ; }       public   string  Name {  get ;  set ; }       public   string  city {  get ;  set ; }      }   We have added isMarried as a Boolean property.   Creating a List of Emp c...

Binding CheckBoxList in ASP.Net MVC

Blogspot Introduction I would like to share how to bind the checkbox list in MVC. I will use a Model (a class file) to define various attributes for checkboxes. For a basic understanding of MVC kindly use the following link: ASP.NET MVC Overview The following is the procedure. 1. Creating Model We created a "SubjectModel" class under the Models folder and defined the following two properties: Subject: to display text Selected: to display check/uncheck 2. Creating the controller We created a Controller "BindingCheckBoxController" under the controllers folder We created an Action having the name = "DisplaycheckBoxes" We created a list of Subjects (Subject model class) Returning a list of subjects to the View. public  ActionResult DisplayCheckboxes() {     List<SubjectModel> listsubject =  new  List<SubjectModel>();     listsubject.Add( new  SubjectModel( "Physics" , true )); ...