SharePoint:PeopleEditor
AllowEmpty="false"
ValidatorEnabled="true"
id="requesterPicker"
runat="server" ShowCreateButtonInActiveDirectoryAccountCreationMode="true"
SelectionSet="User"
AfterCallbackClientScript="javascript:return getDepartmentsForEmployees();"
Width="300px" />
and the JavaScript function
function getDepartmentsForEmployees()
{
var dropDownListDepartment = document.getElementById(GetClientId("dropDownListDepartment"));
__doPostBack(dropDownListDepartment.id,'');
}
So in the page load of the form I would check the forms "__EventTarget" in the following way.
if (Request.Form["__EventTarget"].ToString().IndexOf("dropDownListDepartment") > 0)
{
bindDepartmentsByEmployeeNumber();
hiddenPeopleEditorNoMatchText.Value = "Y";
}
On my page load it loads the current logged in User in the People Editor Control.
Now if I add a user to the control and press Ctrl+K then it queries the active directory and if is not able to find that user then it displays like this.
Here comes the problem, Now if you do a post back on the page again it again displays "No exact match was found." like the one blow.
I took much time for me to figure out why the control is acting like this. I have even Googled and could not find much. The root cause for this problem is executing a JavaScript on " AfterCallbackClientScript="javascript:return getDepartmentsForEmployees();". If we remove this statement then everything works fine.
I guess this is a Bug in the control and has to be fixed.
Here is the workaround for this Issue. People Editor Control uses "errorLabel" to Display "No exact match was found.". So I have written a JavaScript function to avid this message and called it at the end of the .ASPX page in the script tag
peopleEditorNoMatchTextDisplay();
And the JavaScript Function
function peopleEditorNoMatchTextDisplay()
{
/*This function corrects the Bug from microsoft i.e If we are calling a function like this "AfterCallbackClientScript="javascript:return getDepartmentsForEmployees();" "
* and sometimes if an entry is not resolved in the people picker, we get a message "No exact match was found." and we make it resolved then after every postback on that page
* we still keep getting this message "No exact match was found.". to avoid this message this is the workaround.*/
var hiddenPeopleEditorNoMatchText = getTagFromIdentifierAndTitle("input", "hiddenPeopleEditorNoMatchText", "");
//document.getElementById("ctl00_PlaceHolderMain_hiddenPeopleEditorNoMatchText");
if(hiddenPeopleEditorNoMatchText.value == "N")
{
var requesterPicker_errorLabel = getTagFromIdentifierAndTitle("span", "errorLabel", "");
//document.getElementById("ctl00_PlaceHolderMain_requesterPicker_errorLabel");
requesterPicker_errorLabel.style.display = "none";
}
}
Do let me know if you have figured out better workaround then this.