How can we implement customization and personalization in WebParts?

 Posted by ArticlesMaint on 9/24/2009 | Category: SharePoint Interview questions | Views: 4590

Personalization and customization is  all about improving individual user experience as per personal choices. Every human is different and everybody wants that the world moves as per their individual choice.  Same holds true for websites. For instance your website can have features like weather forecast, business news and sports news. As an admin you have the capability to change the look and feel of the website which gets displayed to all users. Now some individual users would like to only see news and not weather forecast. So the website should provide some kind of functionality where the users can go and personalize their choices so that website behaves according to their choice.

Now from the capability where the admin can change the look and feel is called a customization. This change is reflected to every viewer who comes to the site.  The capability that individual users can either choose to view the news with weather forecast and not is personalization.

Just cutting it short when changes made to site are shared by all users it’s called as customization.  When we make changes to some feature which is only shared and seen by individual users is termed as personalization.


Let’s try understanding personalization and customization in SharePoint using a small sample. Let’s make a label whose text / data can be personalized by every user, but its font size can only be customized by admin. The font size customization activity is only limited to admin and cannot personalized by every end user who logs in to the website.


Let’s create the label webpart which are discussing. So we will create a webpart whose label data can be personalized as per every user and the font size can only be customized by the admin.

The first thing is that we need to create a class for the webpart. Below is the code snippet of the webpart class. We have created two private properties font size and label data.

public class SimpleLabelCustomization : WebPart

private int _intFontSize;
private string _strLblData = "";


Second thing we need to do is define the personalization scope for both of these properties.

We want the label data changes to be personalized as per user. So we need to attribute the personalizable to personalizationscope.user. In order to display description and display name we specified the ‘WebDisplayName’ and ‘WebDescription’.


WebDisplayName("Personalize your Label data"),
WebDescription("This label is a personalized webpart")]
public string LabelData
get { return _strLblData; }
set {_strLblData = value; }

We want font size changes to view by all users so we need to attribute the "personalizable" value to "personalizationscope.Shared".


WebDisplayName("Customize font size for every one"),
WebDescription("This label is a customized webpart")]
public int FontSizeValue
get{ return _intFontSize; }
set{_intFontSize = value; }

Below is the complete code snippet with explanation.



So now that we are done with our webpart we need to deploy the same. You can see the previous question to understand how to deploy a webpart.

Now let’s see the fun of personalization. To personalize the page you need to click on the top right hand corner and then click personalize page. Now if you edit the webpart you will see only the label data can be changed.

This because we have given label data as user based personalization and font size as shared personalization. 


To customize the webpart we need to click on site action and click edit page. You can now see both the properties. The site actions menu can be restricted to administrators to have a better control on customization and personalization.


To see the actual action create two different login’s and change data with each user logged in. You will see that depending with what username you have logged in you will see the label data as per user personalization.


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response