I'm rendering a Comment control on one of my pages. However, it only displays 5 comments before you have to page to the next 5 comments. How do I increase this page size? There is no attribute or webpart property that I can see

<SharePointPortalControls:SocialCommentControl ID="CommentControl" runat="server" />

I have tried:

CommentControl.Attributes.Add("DisplayItems", "10");


CommentControl.Attributes["DisplayItems"] =  "10";

This should do the trick:

PropertyInfo pi = typeof(SocialCommentControl).GetProperty("DisplayItems", BindingFlags.NonPublic | BindingFlags.Instance);
pi.SetValue(CommentControl, 10);

Valid values for DisplayItems property are 1 through 10. If you set it to less than 1 it will be considered as 1 and if you set it to more than 10 it will be considered as 10.

|improve this answer|||||
  • Just saw this, I'll give it a try – Michael Colbs Nov 19 '14 at 18:38

You could directly access the backfield m_displayItems instead of using the property DisplayItems:

FieldInfo fi = typeof(SocialCommentControl).GetField("m_displayItems", BindingFlags.NonPublic | BindingFlags.Instance);
fi.SetValue(CommentControl, 1000);

This way you can use a value greater than 10 (which is restricted in the property setter).

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.