Online Training On SharePoint

Friday, 19 February 2010

Adding Rating Control on a Layout Page in SharePoint 2010

With SharePoint 2010 we can rate individual items which are stored in a library. It is not very intutive to rate the SharePoint Pages which are stored in page library. Users needs to go to Edit Properties and there they see the rating control from where they can rate. I wanted to show this on the page itself so that it is easy for the users to rate any page. For this we can add the SharePoint Rating Control on the Layout Page based on which the page is getting created. I will explain how to do this for the pages which are stored in a page library and are created using Body Only Page Layout:
1. Activate the rating feature for the page library from Settings -- Rating Settings:

2. Now using SharePoint Designer Open the Layout Pages folder and open the Body Only Page Layout.
3. Add the following Register directives at the top of this layout page:
<%@ Register Tagprefix="SharePointPortalControls" Namespace="Microsoft.SharePoint.Portal.WebControls" Assembly="Microsoft.SharePoint.Portal, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
4.Add the AverageRatingFieldControl to the PlaceHolderMain content control:
<SharePointPortalControls:AverageRatingFieldControl id="PageRatingControl" FieldName="Rating (0-5)" runat="server"/>
Need to make sure that the FieldName must match the column name in the list.
(The code may not show properly in the Firefox)
5. It may be required to do a IIS reset.
6. Once this is done if you create a new page in SharePoint using this layout you will see that rating control will appear on the page and user can easily do the rating:
Post a Comment
Related Posts with Thumbnails