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.
Hi
ReplyDeleteYour post is very useful.
But i have different issue.
During postbacks the people editor control is unable to persist its content.
Do u find this bug? If yes then let me know.
Thanks
Satish
I have been using active directory as data source and values are persisting for me. Place a text box in the webform and check if its value is persisting during postback. If it is not persisting then thenyou have to set the property "EnableViewState" Property to true in the page.
ReplyDelete~Bharat
I am having the same issue with persisting the value. It looks like the view state does not hold the value after 2 postbacks. Has anyone else had a problem with this??
ReplyDeleteIn my .ascx page, when i add PeopleEditor into this page, system say 'User' could not be set on property 'SelectionSet'.
ReplyDeleteCould everybody help me ?