How to use People Editor Control in MOSS 2010

Posted By  amalhashim On 24 Oct 2010 01:10:40
emailbookmarkadd commentsprint
No of Views:1516
Bookmarked:0 times
Votes:0 times

Introduction

People 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.

Sign Up to vote for this article
Other popular Tips/Tricks
Comments
There is no comments for this articles.
Leave a Reply
Title:
Display Name:
Email:
(not display in page for the security purphase)
Website:
Message:
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top