Hi! I’m Brad!

I’m an award-winning software developer from Laramie, Wyoming.

Month: December 2014

  • Using the SharePoint Social Comment Web Part

    This issue has been miserably annoying to me, and I have spent a long time figuring out how to appropriately utilize the SharePoint Social Comment Web Part.

    Here’s how to do it.

    I know this works with SharePoint 2010.  This might work in SharePoint 2013…

    1. To your web part project add a reference to the Microsoft.Sharepoint.Portal namespace.  This is NOT listed in the “Extensions” section of Visual Studio, and you’ll need to browse for it.

    c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ASAPI\microsoft.sharepoint.portal.dll

    2. Create a placeholder in your Web Part’s ASCX file…

    <asp:PlaceHolder runat=”server” ID=”plcComments”></asp:PlaceHolder>

    3. Add a SocialCommentsWebPart to the placeholder in your Web Part’s .ascx.cs file

    plcComments.Controls.Add(
    	new Microsoft.SharePoint.Portal.WebControls.SocialCommentWebPart()
    	{
    		WebPartPropertySpecifiedAddress = Page.Request.Url.AbsoluteUri
    	}
    );

    You can replace the Page.Request.Url.AbsoluteUri part with any URL.

    4. The comments form should appear upon page load.   You might need to wrap the code in step 3 with if(!IsPostBack){ … }  but this usually works.