Tuesday, 2 December 2014

SharePoint 2010 Workflow Interview Questions


These are the basic level questions which can be asked in a interview. I will write a separate Post for high-level workflow interview questions.
Q. What is a workflow?
Ans. Workflows are the way an organization functions, a series of actions that correspond to a work process, such as the process for purchase orders.SharePoint 2010 helps you automate these workflows, thereby increasing the efficiency and productivity of the organization.
Q. What are the types of workflow that you can design in SharePoint 2010.
Ans. you can design List Workflows, Reusable List Workflows and Site workflows using SharePoint designer 2010.
Q. What Reusable List Workflows and Site workflows ?
Ans.
Reusable List Workflows -
You can create a reusable list workflow (reusable workflow) in the top-level site in the site collection, and that workflow can be made globally reusable — meaning that the workflow can be associated to any list, library, or content type in the site collection. You can also create a reusable workflow in any subsite in the site collection; this workflow is available for reuse in that particular subsite.
Site workflows - A site workflow is associated to a site — not to a list, library, or content type. So unlike most workflows, a site workflow is not running on a specific list item. Because of this, many of the actions that are available for items not available for site workflows.
Q. Can you modify the Out-of-Box workflows in SharePoint 2010 ?
Ans. In SharePoint 2010, you have an option to customize the Out-of-Box workflows. The four most popular workflows in SharePoint Server 2007 — the Approval, Collect Feedback, Collect Signatures, Publishing Approval workflows — have been completely rebuilt as declarative reusable workflows, meaning that they are now fully customizable in SharePoint Designer 2010.
Q. What are events, actions, conditions and steps?
Ans. Lets look at this one by one.
Events - An event is what starts or initiates a workflow. Events can also be used to manage the timing of actions within a workflow, such as waiting for the status of an item to change. There are three events that can start a workflow:
* An item is created.
* An item is changed.
* A workflow participant clicks a start button on the SharePoint site.

Actions –
An action is the most basic unit of work in a workflow. SharePoint Designer 2010 provides a set of ready-made, reusable actions for you to incorporate into your workflow.
For example, your workflow can:
* Create, copy, change, or delete list items (including documents).
* Check items in or out.
* Send an e-mail message.
Conditions - When you design a workflow, you can use the workflow editor to create rules that apply conditional logic to SharePoint sites, lists, items and content types. A rule establishes a condition where the workflow performs the associated action only if that condition is true. For example, you can create a rule where the workflow sends a reviewer an e-mail message only if an item is created by a specific person.
Q. What are Parallel and Serial actions ?
Ans. When you have more than one action associated with a condition, the actions can be set up to run at the same time (parallel) or one after another (serial), the default.
Q. What are the Types of forms associated with the workflow ?
Ans. With SharePoint Designer 2010, you can create three types of workflow forms:
Initiation form – An initiation form gathers information from the workflow participant when they start the workflow. It is automatically generated when you create the workflow in SharePoint Designer 2010. Initiation forms are displayed to users when they manually start a workflow on a given SharePoint item. With an initiation form, users can specify additional parameters or information about the workflow as it applies to the given SharePoint item.

Task form –
A custom task form allows workflow participants to interact with tasks in the Tasks list specified for the workflow. With the Custom Task Wizard, you can easily create custom form fields and add them to a custom task form. When you finish designing the workflow, SharePoint Designer 2010 automatically generates the InfoPath or ASP.NET forms for your custom tasks.
Reusable workflow – association form – A reusable workflow, by default, only provides the fields common to all items, such as Created and Modified by. This is because a reusable workflow isn’t by default associated with a list, library, or content type. An association form enables you to associate fields with a reusable workflow so that the fields will be available when you design and run the workflow.
Q. When are these forms get created ? And how do you customize it ?
Ans. SharePoint Designer 2010 automatically generates the forms, but you can customize them by going to the settings page for the workflow, in the Forms section, click the form you want to customize. Workflow forms are either InfoPath or ASP.NET pages. They are stored on the SharePoint site with the workflow source files.


Reference:

http://www.learningsharepoint.com/2010/07/26/sharepoint-2010-workflow-interview-questions/

difference between item.update and item.systemupdate


Item.Update()

Updates the item in the database.
Updates the “Modified” and “Modified by” values.
Creates a new version

Item.Systemupdate()

Updates the item in the database.
No changes in the “Modified” and “Modified By” fields.
No new version.
Triggers the item events.

Reference:

http://www.c-sharpcorner.com/Interviews/answer/6620/what-is-the-difference-between-item-update-and-item-system

Create Content Types in SharePoint 2010 Programmatically in VS 2010



Introduction

Today, in this article let's play around with one of the interesting and most useful concepts in SharePoint 2010.
 
Question: What is a content type?

In simple terms "Content types are a reusable set of columns which can be used across multiple lists or libraries. It is called central component to manage metadata".

I think we are now good to go and implement this wonderful concept.

Step 1: Open SharePoint 2010 Central Administration and navigate to the specific site.

Step 2: Open up Visual Studio 2010 and try to select an empty sharepoint project:


 Output1.jpg

Step 3: Select deploy as a farm solution and click on the next - button. Now an empty project will be created:

Output2.jpg

Step 4: Add a new visual webpart for that project.

Output3.jpg

Step 5: The complete code of the visualwebpart1usercontrol.ascx looks like this:

<%@ Assembly="" Name="$SharePoint.Project.AssemblyFullName$" %>
       <%@ Assembly="" Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
              <%@ Register="" TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
                     <%@ Register="" TagPrefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
                           <%@ Register="" TagPrefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
                                  <%@ Import="" Namespace="Microsoft.SharePoint" %>
                                         <%@ Register="" TagPrefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages"Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
                                                <%@ Control="" Language="C#" AutoEventWireup="true" CodeBehind="VisualWebPart1UserControl.ascx.cs"Inherits="ContentTypesProgramaticallyApp.VisualWebPart1.VisualWebPart1UserControl" %>
                                                       <div>
                                                              <center>
                                                                     <table style="font-family: Verdana; font-weight: bold; color: brown;">
                                                                           <tr>
                                                                                  <td>
                                                                                         <asp:Label ID="Label5" runat="server" Text="Please Enter Content Type Name"></asp:Label>
                                                                                  </td>
                                                                                  <td>
                                                                                         <asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
                                                                                  </td>
                                                                           </tr>
                                                                           <tr>
                                                                                  <td>
                                                                                         <asp:Label ID="Label1" runat="server" Text="Please Enter First Column Name"></asp:Label>
                                                                                  </td>
                                                                                  <td>
                                                                                         <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                                                                                  </td>
                                                                           </tr>
                                                                           <tr>
                                                                                  <td>
                                                                                         <asp:Label ID="Label2" runat="server" Text="Please Enter Second Column Name"></asp:Label>
                                                                                  </td>
                                                                                  <td>
                                                                                         <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
                                                                                  </td>
                                                                           </tr>
                                                                           <tr>
                                                                                  <td>
                                                                                         <asp:Label ID="Label3" runat="server" Text="Please Enter Third Column Name"></asp:Label>
                                                                                  </td>
                                                                                  <td>
                                                                                         <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
                                                                                  </td>
                                                                           </tr>
                                                                           <tr>
                                                                                  <td colspan="2">
                                                                                         <asp:Button ID="Button1" runat="server" Text="Create Content Types" BackColor="Orange" onclick="Button1_Click" />
                                                                                  </td>
                                                                           </tr>
                                                                           <tr>
                                                                                  <td colspan="2">
                                                                                         <asp:Label ID="Label4" runat="server"></asp:Label>
                                                                                  </td>
                                                                           </tr>
                                                                     </table>
                                                              </center>
                                                       </div>
 
Step 6: The complete code of the visualwebpart1usercontrol.ascx.cs looks like this:

using System;
using System.Globalization;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
namespace ContentTypesProgramaticallyApp.VisualWebPart1
{
    public partial class VisualWebPart1UserControl : UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            TextBox4.Focus();
        }
        public void Button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(TextBox1.Text) || string.IsNullOrEmpty(TextBox2.Text) || string.IsNullOrEmpty(TextBox3.Text) || string.IsNullOrEmpty(TextBox4.Text))
            {
                Label4.Text = "Please Enter Some Values";
                Label4.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                SPSite site = new SPSite("http://win-5d57sl2rvt1:9107/");
                SPWeb web = SPContext.Current.Web; SPContentType contentType = web.AvailableContentTypes[SPBuiltInContentTypeId.Item];
                SPContentType content = new SPContentType(contentType, web.ContentTypes, TextBox4.Text);
                web.Fields.Add(TextBox1.Text, SPFieldType.Text, true);
                web.Fields.Add(TextBox2.Text, SPFieldType.Text, true);
                web.Fields.Add(TextBox3.Text, SPFieldType.Number, true);
                SPFieldLink link = new SPFieldLink(web.Fields[TextBox1.Text]);
                SPFieldLink link1 = new SPFieldLink(web.Fields[TextBox2.Text]);
                SPFieldLink link2 = new SPFieldLink(web.Fields[TextBox3.Text]);
                content.FieldLinks.Add(link);
                content.FieldLinks.Add(link1);
                content.FieldLinks.Add(link2);
                web.ContentTypes.Add(content);
                content.Update();
                Label4.Text = "Content Type Created Successfully";
                Label4.ForeColor = System.Drawing.Color.Green;
                TextBox1.Text = "";
                TextBox2.Text = "";
                TextBox3.Text = "";
                TextBox4.Text = "";
            }
        }
    }
}

Step 7: Deploy the solution file and add the created webpart to the sharepoint site:

Output4.png
 


Step 8: Adding a new item to the list:

Output5.png
 

Step 9: The item added to the list looks like this:

Output7.jpg
 
 I hope this article is useful for you.

Reference:

http://www.c-sharpcorner.com/UploadFile/54db21/create-content-types-in-sharepoint-2010-programmatically-in/

Content Types in SharePoint 2010


Let's start discussing content types in SharePoint 2010. Content Type Hub is a new concept in SharePoint 2010. But before going into more details, let's first discuss briefly what the content types are.

So our agenda for the discussion is:

  1. What are the Content Types
  2. Problem with Content Types in MOSS 2007
  3. Content Type Hub in SharePoint 2010
  4. How to publish content types on Content Type hub
  5. How to expose published content types for the web applications (How to subscribe the published content types)

What are the Content Types?
  1. Content Types are very important and powerful features in SharePoint.
  2. A Content type is a group of site columns (or metadata), workflows and other settings for the item in the list or document in document library or for SharePoint page.
  3. Content types are reusable component, they are not specific to any list or library or page layout.
  4. Content Type represents group of information with common properties. For example, you are maintaining the list of the employees for your company, but there are different details for the employees who are onsite. So here you can create two different content types; one for onsite employees and another for local employees. You can associate these content types with the Employee list. So whenever you enter the details for an onsite employee you will create the list item from onsite content type. Also by going one more step ahead we can create base content type with common fields (site columns) and derive two content types from base content type.

Some More Details:
  1. We can create content types in SharePoint by the following 3 ways:

    a. From UI
    b. Using CAML (Collaborative Application Markup Language)
    c. Using SharePoint Object Model (i.e. Programmatically)
     
  2. We can associate one content types to multiple lists and libraries
  3. SharePoint comes with several OOB content types.
  4. Content types are always inherited; content types are never created from scratch. So an existing content type is always selected as a base content type for creating a new content type. So we automatically get all the columns from the base content type for the new one.
  5. Content Types are stored in the SharePoint database. Databases are created for the web application. We can view all the content types from content type gallery (Site Action >> Site Settings >>Galleries>>Site Content Types). Content Type gallery is the document library.

    Content1.gif

    Figure. Content Type Gallery option

Problem with Content Types in MOSS
  1. Now suppose I have created a few content types for my site collection in WebApplication1. And now I want to use some of the content types created in webApplication1 for WebApplication2. But I don't have such an option to share the content types in multiple web applications. I need to copy and paste all the content types with code and separately deployment on the WebApplication2.
     
  2. Also then there is no synchronization mechanism between the content types. If I do some modifications in content types for web application1 then I need to do these changes also content types available for web application2.

Content Type Hub in SharePoint 2010
  1. To overcome the above problem SharePoint 2010 introduces a new concept called Content Type Hubs.
  2. Content Type Hub is the centralized place where all content types are published and the web applications which will require the content types will subscribe to the content type hub and can get the published content types from the hub.
  3. Web application which subscribes the published content types also can receive the updates on published content types.
  4. So Content Type hub is nothing but the separate common site collection where all content types will get created.
  5. Now to act as this site collection as a content type hub we need to activate the "Content Type Syndication Hub" site level feature.

    Content2.gif

    Figure. Feature activation required for Content Type hub
     
  6. Once we have activated this feature we will get a link to "Manage publishing for this content type" for every content type setting page as:

    Content3.gif

    Figure. Link for Manage Publishing for this content type

Exposing the Content Types published on Content Type Hub to the web applications
  1. Now to expose our content type created on the hub we need to configure Managed Metadata Service.
  2. Enterprise Metadata Management Service (Metadata Service) allows us to share the content types across the farm.
  3. Next, we need to bind the content type hub with the meta data service, for this go to
    Central Administration >> Application Management>>Manage Service Application.

    Content4.gif

    Figure. Manage service applications option
    If metadata service is already created then we will get two entries, one is the service and one is connection

    Content5.gif

    Figure. Manage Metadata Service Application and Connection Links

    Select the metadata service, click on the Meta data service and click properties button.

    On the properties window, put the URL of content type hub site collection.

    Content6.gif

    Figure. Content Type Hub URL option
    Also, click on metadata connection, click on properties button and make sure that "Consumes content types from the Content Type Gallery at <URL of your content type hub site collection>" check box is checked.

    Content7.gif

    Figure. Managed metadata connection

Publishing the Content Type
  1. Now we can publish any content type from the content type hub site collection, to be used in the other web applications for which this Meta data connection is associated.
  2. Go to the content type setting page, click on the link "Manage Publishing for this content type", and make sure that Publish option button is selected.

    Content8.gif

    Figure. Content Type Publishing options
     
  3. Now these publishing of content types are managed by the timer job which is executed after every 15 minutes and then available to the subscriber web application.

    a. Content Type Hub (Server Job)
    b. Content Type Subscriber (Job for the web application which is subscribing the content types)

Reference:

http://www.c-sharpcorner.com/uploadfile/prasham/content-types-in-sharepoint-2010/

Monday, 1 December 2014

Event Receivers in SharePoint: A complete guide


1. Introduction

While developing any application we need to handle some events. For example, when a new item is added to a list, we may need to perform some action like say, notifying the person who created the list item, or modifying the dependent entries in some other location etc. Handling of such events is facilitated by event receivers. We have many SharePoint event receiver classes in order to handle variety of events.



2. SharePoint Event Receiver types

There are basically two types of event receivers: Synchronous and Asynchronous event receivers.Synchronous event receivers are also known as ‘Before’ event receivers. They are used to perform some custom action before an event occurs. In this case, there is a flexibility of cancelling the event on some conditions so that the event that gets initiated will not occur.
Asynchronous event receivers are also known as ‘After’ event receivers. They are used to perform some custom action after an event occurs. These events are asynchronous because they need not happen immediately after the event is performed. They can happen sometime later also, unlike synchronous event receivers which occur immediately before an event occurs.

3. Classes of Event Receivers

There are fundamentally five classes for Event Receivers for SharePoint 2007.
Microsoft.SharePoint.SPEmailEventReceiver : This provides event handling whenever a  user sends an email to a list on which e-mail feature is enabled
Microsoft.SharePoint.SPFeatureReceiver :  This provides event handling whenever is feature is acted upon
Microsoft.SharePoint.SPItemEventReceiver : This provides event handling whenever any action is performed on a list item
Microsoft.SharePoint.SPListEventReceiver : This provides event handling whenever a list definition is modified like adding or deleting columns and modifying existing columns.
Microsoft.SharePoint.SPWebEventReceiver : This provides event handling whenever a site or a site collection is deleted or moved
Each of the classes has some virtual methods which are to be over-ridden to perform our custom action. Those methods are as follows.



3.1 Site Level Events

Methods under the class SPWebEventReceiver handle site level events. A brief overview of those methods is as follows.
Site Deleted – This occurs after a site collection is deleted.
Site Deleting – This occurs before a site collection is being deleted.
Web Deleted – This occurs after a website has been deleted completely. This is an asynchronous after event.
Web Deleting – This occurs before a website is deleted. This is a synchronous before event.
Web Moved – This occurs after an existing website is moved. This is an asynchronous after event.
Web Moving – This occurs before a website is moved. This is a synchronous event.

3.2 List Level Events

Methods under the class SPListEventReceiver handle list level events. A brief overview of those methods is as follows.
Field Added – This occurs after a field link is added to a list.
Field Adding – This occurs when is field is being added to a content type.
Field Deleted – This occurs after a field is deleted from a list.
Field Deleting – This occurs when a field is being deleted from a list.
Field Updated – This occurs after a field is updated in a list.
Field Updating – This occurs when a field is being updated in a list.

3.3 Item Level Events

Methods under the class SPItemEventReceiver handle item level events. A brief overview of those methods is as follows.
ItemAdded – This occurs after a new item is added to a list. This is an asynchronous after event.
ItemAdding – This occurs before an item is added to a list. This is a synchronous before event.
ItemAttachmentAdded – This occurs after an attachment is added to a list. This is an asynchronous event.
ItemAttachmentAdding – This occurs while an attachment is being added to a list.
ItemAttachmentDeleted – This occurs after an attachment is removed from an item.
ItemAttachmentDeleting – This occurs while an attachment is being removed from an item.
ItemCheckedIn – This occurs after an item is checked in.
ItemCheckedOut – This occurs after an item is checked out.
ItemCheckingIn – This occurs while an item is being checked in.
ItemCheckingOut – This occurs while an item is being checked out.
ItemDeleted – This occurs after an item is deleted from its list.
ItemDeleting – This occurs while an item is being deleted from its list.
ItemFileConverted – This occurs when the type of file is being converted.
ItemFileMoved – This occurs after a file is moved.
ItemFileMoving – This occurs while a file is being moved.
ItemUncheckedOut – This occurs after un-checking an item in a list.
ItemUncheckingOut – This occurs while an item is being unchecked.
ItemUpdated – This occurs after an item is updated.
ItemUpdating – This occurs while an item is being updated.

3.4 Feature Events

Methods under the class SPFeatureReceiver handle events related to feature. A brief overview of those methods is as follows.
FeatureActivated – This occurs after a feature is activated.
FeatureDeactivating – This occurs when a feature is being deactivated.
FeatureInstalled – This occurs after a feature is installed.
FeatureUninstalling – This occurs when a feature is being uninstalled.

3.5 Email Events

Method under the class SPEmailEmailEventReceiver handles the event related to email. A brief overview of the method is as follows.
EmailReceived This occurs after an email message has arrived (to an email enabled list).

4. Binding the Event Receivers

For the event receivers to receive an event, they should be bound to the corresponding objects. This binding can be done in three ways.
Using a feature
Using a content type
Using WSS object model

4.1  Using Feature

In the feature, the elements.xml file should be as follows.
<Elements xmlns=”http://schemas.microsoft.com/sharepoint/“>
……………………
……………………
<Receivers ListTemplateId=”100″>
<Receiver>
<Name>VideoAddedEventReceiver</Name>
<Type>ItemAdded</Type>
<SequenceNumber>20000</SequenceNumber>
<Assembly>MyProject.MyModule.Events, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0b231a5ff63cd9fa</Assembly>
<Class>MyProject.MyModule.Events.VideoAddedEventReceiver</Class>
<Data></Data>
<Filter></Filter>
</Receiver>
………………………………
……………………………..
</Receivers>
</Elements>
Any number of receivers can be bound through one feature.
Limitation: Site level events cannot be registered/bound through the feature because we cannot associate a ListTemplateId with a site.

4.2 Using  Content Type

In a content type, the elements.xml file should be as follows.
<Elements xmlns=”http://schemas.microsoft.com/sharepoint/“>
<ContentType ID=”id” Name=”name” Group=”GroupName” Description=”Description of content type” Version=”0″>
<FieldRefs>
<FieldRef ID=”FIELD ID” Name=”FIELD NAME” />
…………………………
…………………………
</FieldRefs>
<XmlDocuments>
<XmlDocument NamespaceURI=”http://schemas.microsoft.com/sharepoint/events“>
<spe:Receivers xmlns:spe=”http://schemas.microsoft.com/sharepoint/events“>
<Receiver>
<Name> VideoAddedEventReceiver </Name>
<Type> ItemAdded </Type>
<SequenceNumber>20000</SequenceNumber>
<Assembly> MyProject.MyModule.Events, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0b231a5ff63cd9fa </Assembly>
<Class> MyProject.MyModule.Events.VideoAddedEventReceiver</Class>
<Data></Data>
<Filter></Filter>
</Receiver>
</spe:Receivers>
</XmlDocument>
</XmlDocuments>
</ContentType>
</Elements>
The same limitation of ‘using feature’ applies to content type also because a content type cannot be associated with a site.
Sequence Number determines when the event receiver should get executed in case if more than one event receivers are about to be executed. An event receiver with greater sequence number gets executed after its counterpart with lesser sequence number.

4.3 Using WSS object model

The below is a sample code how an event receiver is bound with a list.
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
SPWeb web = properties.Feature.Parent as SPWeb;
web.Lists[“Video Library”].EventReceivers.Add(
SPEventReceiverType.ItemAdded,
“MyProject.MyModule.Events, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0b231a5ff63cd9fa”,
” MyProject.MyModule.Events.VideoAddedEventReceiver “);
}
In the above code, the custom class ‘VideoAddedEventReceiver’ of type ‘ItemAdded’ is bound with a list named ‘Video Library’.

5. Unbinding SharePoint Event Receiver

• Event receiver bound with the help of content type cannot be unbound.
• If the event receiver was bound with the help of a feature, deactivating the feature would unbind the event receiver from its associated object.
• If the event receiver was bound using WSS object model,
1. Move to the object (site collection or website or list) to which the event receiver is bound.
2. Retrieve the event receiver definition of the intended event receiver.
3. EventReceiverDefinitionObject.Delete().
4. Call the update of that object (site collection or website or list).



















Reference:

http://beginnersbook.com/2013/02/event-receivers-in-sharepoint/

SharePoint WebPart Life-Cycle Events and Event Sequence


Like Asp.Net life cycle there is also Web Part life cycle. So it is better to understand the web part life cycle. I’ve explained some of them which are used by every developer to cover most of the requirements:
OnInit: This method handles initialization of the control.
OnLoad: This event handles the Load event. This is also used for initialize the control but is not intended for loading data or other processing functionality.
CreateChildControls: This is the most popular event in 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.

Reference:

http://geekswithblogs.net/KunaalKapoor/archive/2012/07/18/sharepoint-webpart-life-cycle-events-and-event-sequence.aspx