February 14, 2012

Cannot set Note Board Web Part title in Page Layout

Challenge

When adding SocialCommentWebPart to your Page Layout with SharePoint Designer and trying to set the title of the web part, you cannot do it. SPD removes the Title attribute when you save the Page Layout file.

Here are the exact steps.
  1. Check out Page Layout file in SPD 
  2. Edit File in Advanced Mode 
  3. SocialCommentWebPart looks like this (removed all attributes that are not relevant):

    <SPSWC:SocialCommentWebPart runat="server" Title="" ...></SPSWC:SocialCommentWebPart>
  4. Add Title for the SocialCommentWebPart using the Tag Properties Task Pane in SPD 
  5. SocialCommentWebPart looks like this:

    <SPSWC:SocialCommentWebPart runat="server" Title="Comments &amp; Questions" ...><SPSWC:SocialCommentControl runat="server">
    </SPSWC:SocialCommentControl>
    </SPSWC:SocialCommentWebPart>
  6. Save Page Layout file in SPD by clicking Save 
  7. Check In the Page Layout file and select Publish a major version 
  8. Verify that the Page Layout file still contains SocialCommentWebPart tag and Title as in step 5. 
  9. Close Page Layout file in SPD 
  10. Edit the Page Layout File in Advanced Mode in SPD (do not check out the file) 
  11. SocialCommentWebPart tag has reverted to what it was in step 3

    <SPSWC:SocialCommentWebPart runat="server" Title="" ...></SPSWC:SocialCommentWebPart>
  12. Obviously using that Page Layout will result in SocialCommentWebPart having Untitled title 

Solution

According to Microsoft support, this is by-design and a feature of the product. To alter this functionality I created a simple jQuery script to change the title of the web part and placed the script in my .master page.

ExecuteOrDelayUntilScriptLoaded(function () { $(function() { // Set Note Board title $('td[title="Untitled"] span:first').html("Comments & Questions"); }); }, "sp.js");

There is also a PowerShell based workaround for this that might work in some cases here.

Technorati Tags: SharePoint,jQuery

6 comments:

  1. This helped me out after so much frustration! Thanks a lot!!

    ReplyDelete
  2. Typical Microsoft. Too arrogant to admit this is a bug. Seriously, who would leave a title out of a web part "by design".

    ReplyDelete
  3. This comment has been removed by a blog administrator.

    ReplyDelete
  4. This comment has been removed by a blog administrator.

    ReplyDelete
  5. This comment has been removed by a blog administrator.

    ReplyDelete
    Replies
    1. Dear Mr. Cock,
      Please stop spamming my blog.

      Delete