IntroductionPeople editor can be used whenever we want the user to select user, AD groups or SharePoint groups. For using the control, 1st we need to register the assembly as shown below Html Code <%@ register tagprefix="SharePointWebControls" namespace="Microsoft.SharePoint.WebControls"
assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, Publictoken="378sda87213"/> Once this is done, we can use the following tag for placing the control <SharePointWebControls:PeopleEditor ID="ppeUser" runat="server" Rows="1"
CheckButtonImageName = "/_layouts/Images/user.png"
BrowseButtonImageName = "/_layouts/Images/addressbook.png"
PlaceButtonsUnderEntityEditor="false" MultiSelect="false" AutoPostBack="true"/> In C#, the following code demonstrate the usage this.ppeUser.CommaSeparatedAccounts; Using the above code we can get information user has selected/entered in the people editor control. public static void UpdatePeoplePicker(string login, PeopleEditor editor)
{
ArrayList list = new ArrayList();
PickerEntity entity = new PickerEntity();
entity.Key = login;
entity = editor.ValidateEntity(entity);
list.Add(entity);
editor.UpdateEntities(list);
}The above code can be used to update the People Editor control using code.
We can restrict the selection of the People Editor using the SelectionSet property. It accepts the following values
User – In case the selection to be restricted only for users AD – In case the selection to be restricted only for AD groups SPGroup – In case the selection to be restricted only for SharePoint Groups
Hope this was helpful. |