Posts

Showing posts from March, 2013

How to: Follow documents and sites by using the .NET JavaScript object model in SharePoint 2013

Scenario is here we will create one sample user control, which will have simple one star which we can place on our page to follow the site/documents using JavaScript object model. 1. Visual Studio 2012, SharePoint project. 2. Add new item, web user control and give a name : favoriteControl.ascx 3. <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="FavoriteControl.ascx.cs" Inherits="test.FavoriteControl" %> <div class="favIcon" runat="server" id="favoriteLink"><a href="#" runat="server" id="favorite" onclick="javascript:Follow();"></a></div> 4. Add Script file to project, named favoritehelper.js and paste the following code: $(document).ready(function () { // Ensure that the SP.UserProfiles.js file is loaded before the custom code runs. //SP.SOD.executeOrDelayUntilScriptLoaded(loadUserData, 'sp.userprofiles