jump to navigation

ASP.NET Page lifecycle May 26, 2008

Posted by fofo in .NET, asp.net, asp.net 2.0.

In this post i am going to try to give you an overview of the events that take place in asp.net lifecycle.

Well, most developers and more specifically beginners in web development with the .Net platform want to create web forms and pages right away. As they build more complex applications they need to understand the internals and the sequence of events in a web’s page lifecycle.

There are 3 phases in page construction also known as page lifecycle. These are:

  • Initialisation
  • Event Handler Execution
  • Rendering

We are going to look into those 3 major phases. We must keep in mind that page lifecycle is just a part of the entire Application lifecycle.


In this phase the objects that represent the page controls are instantiated and set to their initial properties.

3 main events happen in this phase:

  • PreInit(In this event we can write code to set dynamically a theme or a master page)
  • Init
  • InitComplete

Event Handler Execution

Afer everything is being lodaded in its inital state, the control’s specific events fire. The order of events is this

  • Preload
  • Load (We write lots of initialisation code in this event)
  • Controls events (Changed events, PostBackEvent and validation events are fired)
  • Load Complete



In this phase the control tree is translated into HTML. Keep in mind that our browser understands HTML only…. The main events in this phase are:

  • PreRender (the databind method is called)
  • SaveState(happens after the ViewState for the page has been created and set)
  • Render(Each control calls its Render method and outputs HTML)
  • Unload(After the markup is created for the whole page and sent back to the http application each object that was instantiated is unloaded and is available for garbage collection)

You cannot remember all these events.But having a clue about the basic course of events helps a lot when you have debugging issues and have architectural dilemmas about your application.




Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: