2
votes

I need to programmatically, using C#, add the SharePoint Web Part "Site Users" to a page.

I know how to add web parts but how do I get the "Site Users" web part from Share Point? I do not know how to instance it.

Thanks for helping.

1
if ( Homework ) return re-tag;Ahmed Ghoneim
Why would you suspect this to be homework?Ryan
No, this is not homework. It is work. I found something called Members Web Part is this something like the "Site Users" Web Part?carruw

1 Answers

2
votes

The answer turned out to be the Members Web Part.

By simply setting "Display Type" to "WebUserGroups" the web part lists the groups and users on the site.

MembersWebPart membersWebPart = new MembersWebPart();
                membersWebPart.DisplayType = MembersWebPartDisplayType.WebUserGroups;
                membersWebPart.Title = "Användare och grupper";

                wpManager.AddWebPart(membersWebPart, "Right", 2);