Sunday, April 1, 2012

Overriding context of AverageRating Control of SharePoint 2010

Share/Save/Bookmark

SharePoint uses AverageRatingControl to display the rating(5 star) for any item. So i have used the same control to display for all the list items on a home page, but the tricky thing is that the control takes the context of the current page but not the list item it is supposed to represent. To do that i have to follow the below code to set or override the context of the item.


HttpContext context = HttpContext.Current;
SPServiceContext serviceContext = SPServiceContext.GetContext(SPServiceApplicationProxyGroup.Default, SPSiteSubscriptionIdentifier.Default);
averageRatingControl.ItemContext = = SPContext.GetContext(context, report.ItemId, listID, SPContext.Current.Web);

  Subscribe

No comments:

Post a Comment