Use PeopleEditor (People Picker) in SharePoint Custom App Dev
How to add the PeopleEditor (People Picker) control to your custom application development (ASPX, user controls, web parts, etc.)
The control we are interested in is the Microsoft.SharePoint.WebControls.PeopleEditor control.
First, we need to add a reference to the Namespace containing our control:
<%@ Register Tagprefix="wssawc" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
Next, add the PeopleEditor control to your page:
<wssawc:PeopleEditor
AllowEmpty="false"
ValidatorEnabled="true"
id="userPicker"
runat="server"
ShowCreateButtonInActiveDirectoryAccountCreationMode="true"
SelectionSet="User" />
Next, add an object on the server to work with the control:
using Microsoft.SharePoint.WebControls; //add a reference to Microsoft.SharePoint.dll if needed
public class MyPageName : Page
{
protected PeopleEditor userPicker;
…
}
Now, add your code needed to retrieve the entities:
public void btnSave_Click(object sender, System.EventArgs e)
{
….
PickerEntity pe = (PickerEntity)userPicker.Entities[0]; //gets first user in list
string username = pe.Description;
…
}
Notes:
The Description property will return the full account name (e.g. domain\username)
The DisplayText property will return the resolved name in the editor control (e.g. First Last)
Comments
- Anonymous
February 06, 2008
PingBack from http://www.travel-hilarity.com/airline_travel/?p=1274