In this article I am going to show how we
can use People Picker Control in SharePoint.
Step
1: Open Visual Studio -> Create New Empty SharePoint Blank Project ->
Name as MySPSIte.
Step
2: Add New Item -> Add New aspx page name as GetUserInfo.aspx. Below is the
aspx code:
Now
Solution Explorer will look like below:

Image
1.
<%@Assembly Name="$SharePoint.Project.AssemblyFullName$"%>
<%@Import
Namespace="Microsoft.SharePoint.ApplicationPages"%>
<%@Register
TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"
Assembly="Microsoft.SharePoint,
Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%>
<%@Register
TagPrefix="Utilities" Namespace="Microsoft.SharePoint.Utilities"
Assembly="Microsoft.SharePoint, Version=14.0.0.0,
Culture=neutral,
PublicKeyToken=71e9bce111e9429c"%>
<%@Register
TagPrefix="asp" Namespace="System.Web.UI"
Assembly="System.Web.Extensions, Version=3.5.0.0,
Culture=neutral,
PublicKeyToken=31bf3856ad364e35"%>
<%@Import
Namespace="Microsoft.SharePoint"%>
<%@Assembly
Name="Microsoft.Web.CommandUI, Version=14.0.0.0,
Culture=neutral, PublicKeyToken=71e9bce111e9429c"%>
<%@PageLanguage="C#" AutoEventWireup="true"
CodeBehind="GetUserInfo.aspx.cs" Inherits="MySpSite.Layouts.MySpSite.GetUserInfo"
DynamicMasterPageFile="~masterurl/default.master"%>
<asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead"
runat="server">
</asp:Content>
<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<table
cellpadding="4" cellspacing="4"
width="70%" style="border: 1px solid Gray;"
align="center">
<tr>
<td
colspan="4" style="background-color: #F5F5F5; font-weight:
bold; font-size: 12pt;">
People Picker
Control
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblUser" runat="server"Text="Select
User:" Font-Size="10pt"></asp:Label>
</td>
<td
align="left">
<SharePoint:PeopleEditor ID="peopelID" runat="server" Width="250px"
Style="padding: 5px;"
BorderColor="#e8e8e8"
BorderWidth="1px" BorderStyle="Solid"
MaximumEntities="1"MultiSelect="false"
AllowEmpty="false" ErrorMessage="Please
Enter a User" ValidatorEnabled="true">
</SharePoint:PeopleEditor>
<asp:TextBox CssClass="input-brd" ID="txtUserId" runat="server"
MaxLength="50" Visible="false"></asp:TextBox>
<asp:Button ID="btnGetInfo" runat="server" Text="Get
All Info" OnClick="GetUserInfo_Click"/>
</td>
</tr>
<tr>
<td
style="background-color: #F5F5F5;" colspan="4">
Selected User
Information
</td>
</tr>
<tr>
<td
colspan="4">
<table
cellpadding="4" cellspacing="4"
width="80%" style="border: 1px solid Gray;" align="center">
<tr>
<td
width="250px">
Display Name :
</td>
<td>
<asp:Label ID="lblDisplayName" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td
width="250px">
Account Name :
</td>
<td>
<asp:Label ID="lblAccountName" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td
width="250px">
Email :
</td>
<td>
<asp:Label ID="lblEmail" runat="server"></asp:Label>
</td>
</tr>
</table>
</td>
</tr>
</table>
</asp:Content>
<asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">
People Picker Control
</asp:Content>
<asp:Content ID="PageTitleInTitleArea" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea"
runat="server">
People Picker Control
</asp:Content>
Here
in SharePoint:PeopleEditor you can set MaximumEntities to search no. of
users.
Myaspx.cs code is:
using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using System.Collections;
namespace MySpSite.Layouts.MySpSite
{
public partial class GetUserInfo : LayoutsPageBase
{
protected void Page_Load(object sender, EventArgs
e)
{
}
protected void GetUserInfo_Click(Object
sender, EventArgs e)
{
for (int i = 0; i < peopelID.ResolvedEntities.Count;
i++)
{
PickerEntity picker
= (PickerEntity)peopelID.ResolvedEntities[i];
Hashtable hstEntityData
= picker.EntityData;
lblDisplayName.Text = picker.DisplayText;
lblAccountName.Text = Convert.ToString(hstEntityData["AccountName"]);
lblEmail.Text = Convert.ToString(hstEntityData["Email"]);
}
}
}
}
Now Deploy the solution.
Try to access your page by using URL: http://localhost:7000/_layouts/MySPSite/GetUserInfo.aspx
Image 2.
Now click icon to search users. Type your
user name and click on search icon. . . Select your user and click on OK button

Image 3.
Now click on Get All Info button to display
of this selected user..

Image 4.