New ASP.NET 2.0 page life cycle events

by lichen 3/29/2006 3:44:00 PM

It is a nice feature in ASP.NET that we can access the properties of controls instead of working with request and respond objects directly. However, the nice feature comes with a price: we need to know the page life cycle to know when we can get and set the state of controls. In ASP.NET 1.x, we usually work with Init, Load, Databinding and PreRender events. It as a small learning curve but once we got over it things were working predictably.

In ASP.NET 2.x, the number of events grew considerably bigger. The following events were added:

PreInit

InitComplete

PreLoad

LoadComplete

SaveStateComplete

PreRenderComplete

I had a pretty good use case fore PreInit. If we need to dynamically change them or master page, we need to do it in PreInit.

I found a good use case for PreRenderComplete today. In ASP.NET 1.x, if I want to modify the result of databinding, I usually do it in databound event of a control or the Page_PreRender event. However, in ASP.NET 2.x, a menu would not bind to a SiteMapDatasource until after the PreRender event; anything I do in PreRender is erased. If I need to append my item to the menu dynamically, I have to do it in PreRenderComplete event.

In anyone knows good use case for other events, please let me know.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

.Net | ASP.NET

Related posts

Comments

Comments are closed

Powered by BlogEngine.NET 1.2.0.0
Theme by Mads Kristensen

About the author

Name of author Author name
Something about me and what I do.

E-mail me Send mail

Calendar

<<  May 2012  >>
MoTuWeThFrSaSu
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

View posts in large calendar

Pages

    Recent comments

    Authors

    Tags

      Disclaimer

      The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

      © Copyright 2012

      Sign in