0

我有 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”按钮时,User1 已成功添加到 PeopleEditor。但是,当我加载页面并使用默认对话框(浏览)在 PeopleEditor 中添加 User2,然后单击按钮添加第二个用户(User1)时,User2 仍保留在 PeopleEditor 中,但 User1 未添加到 PeopleEditor。使用标准添加对话框后,如何以编程方式在 PeopleEditor 中添加用户?

4

0 回答 0