views:

519

answers:

2

trying to set default value in the people picker with an update panel. On a test page without an update panel, the code

PeopleEditor1.CommaSeparatedAccounts = "domain\\user.account";

works just fine. As soon as I add an update panel around that people editor the picker's text area gets cleared out and future calls to the above snippet are ignored. This can be reproduced by placing the following on a fresh aspx page w/ code-behind.

code-behind:

protected override void OnLoad(EventArgs e)
{
    base.OnLoad(e);
    PeopleEditor1.CommaSeparatedAccounts = "domain\\user.account";
}

aspx source:

<asp:ScriptManager runat="server" id="ScriptMan">
</asp:ScriptManager>
<asp:CheckBox runat="server" ID="causepostback" AutoPostBack="true" Text="Should this be checked?" />
<asp:UpdatePanel runat="server" ID="candypanel" UpdateMode="Conditional">
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="causepostback" />
    </Triggers>
    <ContentTemplate>
        <SharePoint:PeopleEditor runat="server" ID="PeopleEditor1" MultiSelect="true" 
                AllowEmpty="false" SelectionSet="User,SecGroup,SPGroup" AutoPostBack="false" 
                BorderWidth="1" Width="265px" PlaceButtonsUnderEntityEditor="false" Rows="1" />        
    </ContentTemplate>
</asp:UpdatePanel>

Your insight is appreciated.

A: 

Did you resolve the issue? I'm having the same issue.

rjn
I did not, I'm afraid. I ended up adding a list of users, each with a "remove" button so I could use the people picker as an "insert only" control. Unfortunate.
kalebd
A: 

As PeoplePicker is internally using its own Ajax request to update it self,we have this issue. I found below two example to solve the issue.

  1. Simple Way Using Hidden Field & Javascript
  2. Bit complex using jQuery
Kusek