order of Event Handling and Posting Page_Load..?

C

cj

I am using datagrids with buttoncolumn etc. I am trying to understand the
order of events.

If a user clicks on a ButtonColumn button, what is the order of events after
that? Does the event-handler subroutine happen before the Page_Load
subrouting, or the other way around?

Also, I assume the state of any variables etc will be updated before either
Page_Load or event handler subroutines?

Can someone please clarify this?

Thanks

cj
 
T

Teemu Keiski

Hi,

Page_Load happens always before postback events. And other way around,
postback events raised by controls are raised always after Page_Load.

With State of variables : if you mean local variables / members on the Page
they do not keep their state by default (Page class is recreated for every
request), however those which utilize ViewState (controls itself do), they
do keep their state and are restored to the state (from previous
postback/request by the same user) before Pgae_Load (actually right after
Page_Init)

In case you are interested in the Page lifecycle (the phases during one
request).

ASP.NET 1.0/1.1

1. Instantiate
2. Initialize
3. TrackViewState
4. LoadViewState (postback)
5. Load postback data (postback, IPostBackDatahandler.LoadPostdata)
6. Load
7. Load postback data for dynamical controls added on Page_Load (postback)
8. Raise Changed Events (postback,
IPostBackDatahandler.RaisePostDataChanged)
9. Raise postback event (postback, IPostBackEventHandler.RaisePostBackEvent)
10.PreRender
11. SaveViewState
12. Render
13. Unload
14. Dispose

ASP.NET 2.0 has added a support for a few more stages. Here's a nice diagram
of all the relevant phases in v2

http://hydrate.typepad.com/leo/2004/08/the_aspnet_v20_.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top