SharePoint PeopleEditorを使用した単純なページがあります:PickerPage.aspxのコード:
<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<table border="0" cellspacing="0" cellpadding="0" class="ms-propertysheet" width="100%">
<wssuc:InputFormSection Title="People Editor" runat="server">
<Template_InputFormControls>
<wssuc:InputFormControl LabelText="Select Users:" runat="server">
<Template_Control>
<SharePoint:PeopleEditor AllowEmpty="true" ValidatorEnabled="true" ID="RespondentPeopleEditor" runat="server" MultiSelect="true" Width="280"
DialogHeight="400" DialogWidth="500" DialogTitle="Choose"
ShowCreateButtonInActiveDirectoryAccountCreationMode="true" SelectionSet="User" />
</Template_Control>
</wssuc:InputFormControl>
</Template_InputFormControls>
</wssuc:InputFormSection>
</table>
<asp:Button runat="server" ID="AddBtn" Text="Add User1" OnClick="AddBtn_Click" UseSubmitBehavior="false" />
</asp:Content>
PickerPage.aspx.csのコード:
public partial class PickerPage2 : LayoutsPageBase
{
protected PeopleEditor RespondentPeopleEditor;
protected Label ResultLbl;
protected Button AddBtn;
protected void Page_Load(object sender, EventArgs e)
{}
protected void AddBtn_Click(object sender, EventArgs e)
{
string accs = RespondentPeopleEditor.CommaSeparatedAccounts;
if (!String.IsNullOrEmpty(accs)) accs += ",";
accs += "domain\\user1";
RespondentPeopleEditor.CommaSeparatedAccounts = accs;
}
}
ページを読み込んで[ユーザーの追加]ボタンをクリックすると、User1がPeopleEditorに正常に追加されました。しかし、ページをロードし、デフォルトのダイアログ(参照)を使用してPeopleEditorにUser2を追加し、その後ボタンをクリックして2番目のユーザー(User1)を追加すると、User2はPeopleEditorに残りますが、User1はPeopleEditorに追加されません。標準の追加ダイアログを使用した後、プログラムでPeopleEditorにユーザーを追加するにはどうすればよいですか?