Important point that we need to remember while creating a webpart to render a PeopleEditor control with default values

Consider you have requirement to create a webpart which will render a PeopleEditor control with some default values. We have a facility to give the default values to the PeopleEditor control using the CommaSeparatedAccounts property of that control.


While developing that web part if you supply the default values to a people editor control via “CommaSeparatedAccounts” property of PeopleEditor Control from outside the CreateChidControl() method [For eg: in the Render(), RenderContents() or RenderControl() method] then it won’t display the values while rendering it in the webpart.


While rendering the webpart, it will just show as below image. If we press Ctrl + K or click on the first image in the bottom right of that control, then it will show the users correctly but by default it won’t show, instead it will display “No exact match was found” message.



PeopleEditor control will display the CommaSeparatedAcccounts value only if we provide the values to that property before adding it to the control array. That means we have to provide the values inside the CreateChildControl method.


Here I am giving sample code to do that.




PeopleEditor qEditor = null;

protected override void CreateChildControls()


qEditor = new PeopleEditor();
qEditor.AutoPostBack = false;
qEditor.PlaceButtonsUnderEntityEditor = true;
qEditor.ID = "pplEditor";
qEditor.AllowEmpty = false;
qEditor.SelectionSet = "User";
qEditor.MultiSelect = true;

// here we can provide the default values to the people editor control
qEditor.CommaSeparatedAccounts = "Domain\username1,Domain\username2";




PeopleEditor control:


Comments (0)

Skip to main content