Sharepoint People Editor within Update Panel - Cannot set value after partial postback
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(EventA开发者_StackOverflow中文版rgs 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.
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.
- Simple Way Using Hidden Field & Javascript
- Bit complex using jQuery
精彩评论