使用“浏览对话框”添加用户后,无法以编程方式在PeopleEditor中添加用户帐户

时间:2012-06-13 17:45:50

标签: c# sharepoint

我有一个使用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中添加用户?

0 个答案:

没有答案