I encountered an odd behavior with the SharePoint PeopleEditor control about a week ago. Initially, I added the PeopleEditor control to the web form (see below) and everything worked perfectly. I was able to search for users, validate users, and was able to get the value out of the control on submit by accessing userpicker.Entities in code.
<%@ Register Tagprefix=”pp” Namespace=”Microsoft.SharePoint.WebControls” Assembly=”Microsoft.SharePoint, Version=22.214.171.124, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
Add control to your code
<pp:PeopleEditor AllowEmpty=”false” ValidatorEnabled=”true” id=”userPicker” runat=”server” ShowCreateButtonInActiveDirectoryAccountCreationMode=”true” SelectionSet=”User” />
The decision was made to ajax enable the form so I wrapped all of the controls in an ajax panel. Since the PeopleEditor was not a required field I also set ValidatorEnabled=”false” and hid the control from the user when not in use. This is when I noticed that the PeopleEditor was no longer maintaining the selected user in userpicker.Entities on form submit. My initial thought was that the PeopleEditor control would not work while contained in an ajax update panel. After testing and scouring the web for answers, this was not the case. I also searched to determine if hiding the control on the form was causing this problem. It wasn’t… Turns out that when I reset the ValidatorEnabled=”true”, the control started working again. Apparently it is necessary to have that property set to true when working with partial post backs in a form. Long story short, with some simple code to handle the PeopleEditor validator on the Page.IsValid method, I was able to get the control to function properly and return the selected user on form submit. I’m sure that there are other methods to get beyond this issue but for a quick and easy way, this should get you going.
Hope you find this helpful when dealing with the SharePoint PeopleEditor Control.
Summit 7 Systems
The sample scripts are not supported under any Summit 7 Systems standard support program or service. The sample scripts are provided AS IS without warranty of any kind. Summit 7 Systems further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Summit 7 Systems, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Summit 7 Systems has been advised of the possibility of such damages.