ASP.NET Page Events Lifecycle

When using  master pages, the normal page event lifecycle is a little different. Here is the actual order:

  1. Page.OnPreInit
  2. MasterPageControl.OnInit (for each control on the master page)
  3. Control.OnInit (for each contol on the page)
  4. MasterPage.OnInit
  5. Page.OnInit
  6. Page.OnInitComplete
  7. Page.LoadPageStateFromPersistenceMedium
  8. Page.LoadViewState
  9. MasterPage.LoadViewState
  10. Page.OnPreLoad
  11. Page.OnLoad
  12. MasterPage.OnLoad
  13. MasterPageControl.OnLoad (for each control on the master page)
  14. Control.OnLoad (for each control on the page)
  15. OnXXX (control event)
  16. MasterPage.OnBubbleEvent
  17. Page.OnBubbleEvent
  18. Page.OnLoadComplete
  19. Page.OnPreRender
  20. MasterPage.OnPreRender
  21. MasterPageControl.OnPreRender (for each control on the master page)
  22. Control.OnPreRender (for each control on the page)
  23. Page.OnPreRenderComplete
  24. MasterPageControl.SaveControlState (for each control on the master page)
  25. Control.SaveControlState (for each control on the page)
  26. Page.SaveViewState
  27. MasterPage.SaveViewState 
  28. Page.SavePageStateToPersistenceMedium
  29. Page.OnSaveStateComplete
  30. MasterPageControl.OnUnload (for each control on the master page)
  31. Control.OnUnload (for each control on the page)
  32. MasterPage.OnUnload
  33. Page.OnUnload



  • I'm sorry but this sounds like an extremely biased submission. How many times have you have to utilize each and every one of these events?
    The Asp.Net postback functionality gives a lot of functionality out of the box. The average development shop does not have developers who have mastered SOLID principles, read every one of Uncle Bob's books, implemented TDD with mocks and 85% code coverage etc etc. For most of these shops, web forms IS simpler. And utilized correctly, (ControlState instead of ViewState etc), it is possible to do RAD development while at the same time building highly scalable apps.

  • I agree with Dilip: these events actually DO make things simpler, in my opinion! :-)

  • Absolutely agree with Dilip and Ricardo!

    MVC is the next "big" thing from MS. As we all now and see every now and again (every 3 years on average), not every new thing from MS is necessarily better than the old proven things.

    As a web developer at any level, you'd never use all of these events. The .net framework gives you the functionality to do as you see fit in different situations.

    It's obvious that the author of the "article" is extremely biased, most likely because they haven't got the knowledge or experience to use Web Forms properly.

    The grass is not always greener with new technologies..

  • Webforms is a good abstraction, and as already pointed out, those events are *there* but you typically implement only a few of them in normal circumstances.

    I like ASP.NET MVC too tho..

  • Excellent summary of the ASP.Net page life cycle. Helped me a lot, thanks a lot.

  • Nice article.

  • Non-digital folks like the print album. ,

  • He would be inclined to call de Vries's mutation theory, figuratively, the quantum theory of biology. ,

  • It is really nice, but it will be more nice if you use Indent:)

  • Why does PreInit gets called only for the content page and not for the master page or user controls

  • Avinash,
    This event only exists in Page, not in Control or MasterPage:

  • nice article,Thanks

  • Thanks for this list, helped find a problem where I had to use OnPreRenderComplete rather than OnPreRender.

  • im really sorry but i dont understand this at all i came here looking for what "the prosection rests its case" means and this comes up??? ok fare enought maybe if i get to learn more about it ill know wat to do otherwise i find it useless for this subject...mii sose assingment is due on friday and no one in mii group is doing any of the work...i have to write the whole script bii mii self...its about a trial at court and we hve to act it out...thnx anyways bii :D

    from cayla :P

  • I found it bit confusing

Comments have been disabled for this content.