Using People Picker in Custom Web Parts

People Picker in web parts:
To get people picker inside web parts, you can use the People Editor class inside Microsoft.Sharepoint.WebControls namespace.

using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.WebControls;

namespace PeoplePickerWebPart.PeoplePicker
    public class PeoplePicker : WebPart
        private PeopleEditor userSelect;
        protected override void CreateChildControls()
            userSelect = new PeopleEditor();
            userSelect.MultiSelect = true;
            userSelect.AllowEmpty = false;
            userSelect.AutoPostBack = false;
            userSelect.PlaceButtonsUnderEntityEditor = true;
            userSelect.ID = "PeopleEditor";
            userSelect.SelectionSet = "User,SecGroup";
            userSelect.Rows = 1;
            //To apply style to people picker
            LiteralControl styleControl = new LiteralControl();
            styleControl.Text = "<style> .ms-inputuserfield{ font-size:8pt; font-family:Verdana,sans-serif; border:1px solid #a5a5a5;} a{color:#000000;text-decoration: none;font-weight:normal;font-style:normal;}{padding-left:1px;padding-top:2px;} </style>  ";


People Picker in User control based web parts:

For user control based web parts, you can simply use the SharePoint’s user control. Here is how:

<%@ Register TagPrefix="spuc" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

Once registered, you can call it anywhere in the user control

<spuc:PeopleEditor ID="PeopleEditor1" runat="server" Width="329px" Height="65px" AllowEmpty="true" MultiSelect="false" SelectionSet="User" />


People Picker in Custom Web Parts

I’ve attached both the projects here.

Thanks to

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

10 thoughts on “Using People Picker in Custom Web Parts

  • September 2, 2014 at 7:13 AM

    Hey Mate,
    Do you know how to use people editor as a web part property??


  • September 16, 2013 at 1:48 PM

    Hi Thanks for the post,
    Can you please tel me how to use people editor in sharepoint sandboxed visual webpart for o365?

    Thanks in advance.

  • July 16, 2013 at 10:19 AM

    Hi It is working fine on IE9.
    However on IE 7, when i click on browse button of people picker, it throws a javascript error:

    “An error has occured on the script of the page”
    Type is undefined.

  • January 9, 2013 at 4:49 PM

    Hi, I have a question, can you tell me how to have one Person from this field to LIST? And in another form I want to get Person from item from this LIST. And I know how exactly…

  • December 7, 2012 at 5:17 AM

    I have exported a list with people picker values. But after importing the list the values are empty. i don know y?

    • December 7, 2012 at 7:36 PM

      Unfortunately, yes this is the default behavior. It does not fix in SharePoint 2010 either. People Picker issues are still alive! But you can paste in multiple names separated by a semicolon, like: #;#;#;

  • August 22, 2012 at 12:32 AM

    I having a problem while using this inside a WebForm,
    I got a javascript error that says “TypeError: a is null”

    Any ideas ?

    • August 22, 2012 at 12:13 PM

      Are you using JQuery? Looks like its from JQuery.


Leave a Reply