Web Part life cycle in SharePoint 2010

This SharePoint 2010 tutorial I will explain the web part life cycle in SharePoint 2010 or web part page life cycle in SharePoint 2010/2013. Learn about the web part life cycle SharePoint 2010.

Web parts are a very important element in SharePoint and As a SharePoint developer, we should know about web part life cycle events. Here we will discuss the web part life cycle in SharePoint.

Web part life cycle SharePoint 2010

Like the Asp.Net lifecycle, there is also a Web Part life cycle in SharePoint 2010. So it is better to understand the web part life cycle of SharePoint.

Below is the web part life cycle SharePoint 2010/2013:

OnInit:
This method handles the initialization of the control.

OnLoad:
This event handles the Load event. This is also used for initializing the control but is not intended for loading data or other processing functionality.

CreateChildControls:
This is the most popular event in the web part life cycle. This creates any child controls. So if you are adding any control to display then you have to write in this method.

EnsureChildControls:
This method ensures that CreateChildControls has executed. EnsureChildControls method must be called to prevent null reference exceptions.

SaveViewState:
View state of the web part saved.

OnPreRender:
This method handles or initiates tasks such as data loading that must complete before the control can render.

Page.PreRenderComplete:
The page fires the PreRenderComplete event after all controls have completed their OnPreRender methods.

Render:
This method is used to render everything.

RenderContents:
Renders the contents of the control only, inside of the outer tags and style properties.

OnUnload:
Performs the final cleanup.

You may also like following SharePoint 2010 tutorials:

I hope this SharePoint tutorial explains web part life cycle in SharePoint 2010 or web part page life cycle in SharePoint 2010/2013

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.

Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SPGuides.com

>