Home > English, Sharepoint > Sharepoint WebPart LifeCycle and Event flow

Sharepoint WebPart LifeCycle and Event flow

Lifecycle events of a Sharepoint Connectable WebPart wih a single ViewState backed property:

On Page Load

  1. Constructor
  2. OnInit
  3. OnLoad
  4. ConnectionConsumer method is called if web part is connectable (sets the connection providers interface in the webpart)
  5. CreateChildControls
  6. OnPreRender (if your web part is connectable you would typically call the connection provider here to retrieve data)
  7. SaveViewState
  8. Render
  9. RenderChildren
  10. RenderContents

On 1st Postback
(PostBack click handler sets ViewState via public Property)

  1. Constructor
  2. OnInit
  3. CreateChildControls
  4. OnLoad
  5. PostBack click handling
  6. ConnectionConsumer method is called if web part is connectable (sets the connection providers interface in the webpart)
  7. OnPreRender (if your web part is connectable you would typically call the connection provider here to retrieve data)
  8. SaveViewState
  9. Render
  10. RenderChildren
  11. RenderContents

On 2nd Postback
(PostBack click handler sets ViewState via public Property)

  1. Constructor
  2. OnInit
  3. LoadViewState
  4. CreateChildControls
  5. OnLoad
  6. PostBack click handling
  7. ConnectionConsumer method is called if web part is connectable (sets the connection providers interface in the webpart)
  8. OnPreRender (if your web part is connectable you would typically call the connection provider here to retrieve data)
  9. SaveViewState
  10. Render
  11. RenderChildren
  12. 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.

source: http://platinumdogs.wordpress.com/2008/10/14/sharepoint-webpart-lifecycle-events/

Chart that shows you how the different events flows from the Page, through the WebPartManager and WebPartZones, to the Web Part:

webparteventmodelchart_2

source: http://www.wictorwilen.se/Post/SharePoint-Web-Part-Event-Flow-in-detail.aspx

Categories: English, Sharepoint Tags:
  1. No comments yet.
  1. No trackbacks yet.