The original post can be found at platinumdogs.wordpress.com.
Visit this arcticle at CodeProject if you need a deeper introduction to SharePoint Web Part's lifecycle events.
This post describes the lifecycle events of a Sharepoint Connectable WebPart wih a single ViewState backed property;
On Page Load
-
Constructor
-
OnInit
-
OnLoad
-
ConnectionConsumer method is called if web part is connectable (sets the connection providers interface in the webpart)
-
CreateChildControls
-
OnPreRender (if your web part is connectable you would typically call the connection provider here to retrieve data)
-
SaveViewState
-
Render
-
RenderChildren
-
RenderContents
On 1st Postback
-
(PostBack click handler sets ViewState via public Property)
-
Constructor
-
OnInit
-
CreateChildControls
-
OnLoad
-
PostBack click handling
-
ConnectionConsumer method is called if web part is connectable (sets the connection providers interface in the webpart)
-
OnPreRender (if your web part is connectable you would typically call the connection provider here to retrieve data)
-
SaveViewState
-
Render
-
RenderChildren
-
RenderContents
On 2nd Postback
(PostBack click handler sets ViewState via public Property)
-
Constructor
-
OnInit
-
LoadViewState
-
CreateChildControls
-
OnLoad
-
PostBack click handling
-
ConnectionConsumer method is called if web part is connectable (sets the connection providers interface in the webpart)
-
OnPreRender (if your web part is connectable you would typically call the connection provider here to retrieve data)
-
SaveViewState
-
Render
-
RenderChildren
-
RenderContents
Note that during the 2nd postback, LoadViewState, is called, since in the 1st postback the click handler sets the value of the ViewState backed public property.
Credits for this post goes to Phil Harding. Thanks Phil for sharing.