OnInit In this event the configuration values can be set using a property bag and those that are in the web part task pane are loaded into the web part. protected override void OnInit(EventArgs e)
{
}
LoadViewState
The view state of the web part is populated here. protected override void LoadViewState(object savedState) //Only at Postback
{ }
OnLoad
This event is for loading the WebPart such as adding controls. CreateChildControls
In this routine control properties and methods previously declared are defined. In most cases, we have to initialize the control's default value (such as Text, Checked, Items, and so on) and activity that is possible to call just at first WebPart load, checking PostBack. The controls specified are created and added to the controls collection. When the page is being rendered for the first time the method generally occurs after the OnLoad() event. In the case of postback, it is called before the OnLoad() event. We can make use of EnsureChildControls() - It checks to see if the CreateChildControls method has yet been called, and if it has not, calls it. } OnPreRender
Here we can change any of the web part properties before the control output is drawn. This is the routine where the control's value is kept for the View State. }
Render
HTML Output is generated. {
}
OnUnload
This is executed when the web part is unloaded. protected override void OnUnload(EventArgs e)
{
}
Dispose This to free the memory.
public override void Dispose()
{
}
protected override void OnLoad(EventArgs e){}
protected override void CreateChildControls()
{
protected override void OnPreRender(EventArgs e)
{
protected override void Render(HtmlTextWriter writer)
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment
It is the same account you read, post and publish with — and you will come straight back to this page.

Satya AryaPosted Mar 16, 2011, 12:44 AM
I am using lots of webparts created in sharepoint 2010. Now we decided that we will convert all webparts created in sharepoint 2010 into asp.net webparts becuase microsoft recommanded asp.net webparts. I have analyzed differences in both webparts, but unable to find key points which proves why should i use asp.net webparts instead sharepoint webparts? My webparts are very typicall having lots of business requirement. Thanks