Вопрос

I tried to create and use a People picker in my custom visual webpart by adding the Tagprefix and the peopleeditor control in my ascx page

<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" 
    Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 

<SharePoint:PeopleEditor ID="ppUsers" runat="server" Width="350px" Height="35px" SelectionSet="User" />

When the solution is deployed , the People picker displays correctly but when I enter a loginname and press return key. It functions like a text control and adds a new line.

Everywhere I have searched i have found that it is to be used as shown above itself. Please help in finding out what I could be doing wrong here.

Thanks.

Это было полезно?

Решение 2

I had to add the control from the code only once with any ID.

This will have created a people picker control at the top of the web part. For odd some reason this enabled all other people picker controls to function correctly.

Then I hid that people picker control created from code inside a panel. If I tried to hide the control from code behind, again none of the people picker controls will work.

After that I was able to use the tag specified in the question multiple times with any different ID and use it anywhere in the design page.

Here is the code. Hope it helps.

 private PeopleEditor userSelect;//For using People picker 

    protected override void CreateChildControls()
    {
            //Create People Picker control
            userSelect = new PeopleEditor();
            userSelect.MultiSelect = false;
            userSelect.ID = "peoplepickerControl";
            userSelect.SelectionSet = "User";
            userSelect.Rows = 1;

            Panel pnlPeoplePicker = new Panel();
            pnlPeoplePicker.ID = "pnlPeoplePicker";
            pnlPeoplePicker.Style.Add("display", "none");

            //Add Control into the panel and add it to the web part
            pnlPeoplePicker.Controls.Add(userSelect);
            this.Controls.Add(pnlPeoplePicker);

            Control control = Page.LoadControl(_ascxPath);
            Controls.Add(control);
        }

Другие советы

Try this,

<SharePoint:PeopleEditor AllowEmpty="true" ValidatorEnabled="true" ID="ped"
AutoPostBack="false"  EnableViewState="true"
runat="server" ShowCreateButtonInActiveDirectoryAccountCreationMode="true" SelectionSet="User"
AllowTypeIn="true" MultiSelect="false" Height="20px" Width="99%" ShowEntityDisplayTextInTextBox="true"
DoPostBackOnResolve="false" />
Лицензировано под: CC-BY-SA с атрибуция
Не связан с sharepoint.stackexchange
scroll top