This is a mirror of official site: http://jasper-net.blogspot.com/

Documenting the Life Cycle of an ASP Page

| Sunday, September 5, 2010
Introduction

When coordinating code between a master page, a child page and several controls, it can be very useful to have a listing of when each event is fired. There are a lot of lists on the web but they are rarely complete, and I have yet to find the code on how the lists were created. In the end I wrote my own testing framework, which is the topic of this article.

It turns out to be very simple: override methods to make a note of what is happening, then continue. I did this by creating custom classes to replace the standard Page and MasterPage objects, and by writing "wrapper" web controls. If you are familiar with these techniques or are just looking for a reference, feel free to go to the Results sections at the bottom.

This article is targeted towards beginner-ish web programmers who already know the basics of web programming and have a test site where they can experiment. It was written and tested using ASP.Net 2.0, but there's nothing here that should break with any later versions of .Net. I used VB because that is the language I use every day; the code is simple and should translate into C# very easily.

Results, Test 1 - Master and Child

We are ready for our first test. Open a browser and point it to the child page you just created.

Child PreInit
Master Init
Child Init
Child InitComplete
Child PreLoad
Child Load
Master Load
Child LoadComplete
Child PreRender
Master PreRender
Child PreRenderComplete
Child SaveViewState
Master SaveViewState
Child SaveStateComplete
Child RenderControl
Child Render
Child RenderChildren
Master RenderControl
Master Render
Master RenderChildren

Read more: Codeproject

Posted via email from .NET Info

0 comments: