Search This Blog

Friday, 25 February 2011

SharePoint PeoplePicker in

PeoplePicker can be added at runtime using PeopleEditor class.

PeopleEditor projectManager = new PeopleEditor();

//To insert value in SharePoint List

We need to create SPUser object
SPUser objUser = SPContext.Current.Web.User[peopleContact.CommaSeparatedAccounts];
String strUserToInsert = objUser.ID + ";#" + objUser.Name;
item["ProjectManager"] = objUser; // ProjectManager ---> Column in List

//To derive EmailId of ProjectManager
string projectmanagerEmailId = objUser.EmailId.ToString();

//To derive LoginId of ProjectManager
string loginProjectManager = objUser.LoginID.Tostring();

Similarly other details can be fetched.

//Important Properties

1.  projectManager .MultiSelect = true or false;  //Allows either multiple selection of users or single selection user.

2. projectManager.AllowTypeIn = true or false //to specify if the user can type the user name in the text box, or if he must use the browse window popup


No comments:

Post a Comment