سؤال

I have a PeopleEditor in my ASPX page:

<SharePoint:PeopleEditor ID="ccAuthor" runat="server" SelectionSet="User" MaximumEntities="1" />

And access its contents when the corresponding save button is clicked:

<asp:LinkButton ID="lnkUpdateCcAuthor" runat="server"
    OnCommand="LinkPostbackCommand"
    CommandName="UpdateCcAuthor" CommandArgument="">
    <asp:Image ID="imgCcAuthor" runat="server" ImageUrl="/_layouts/images/save.gif"
        style="border-width: 0px;" AlternateText="Update CC-Author for selected Task" />
</asp:LinkButton>

This works fine when adding people, but I cannot remove them.

This code

string[] accounts = editor_.CommaSeparatedAccounts.Split(',');

Executed upon the PostBack of the Update button always contains the account that was in the PeopleEditor initially, although the form control is empty when I click Update.

What is going on here? Why can't I remove the account?

هل كانت مفيدة؟

المحلول 2

I had a talk with the customers and we decided to just circumvent the issue by having a "Clear" Button next to the picker and then clear it in the PostBack.

This way, we don't need extra JS / other Code and can always be sure that the clearing works.

نصائح أخرى

There might below reasons that values are not getting cleared.

  1. are you binding people picker field on page load ? If so are you assiging value to it in if (!IsPostBack). This is necessary because it might be case that you page load is getting executed before you update click event and so your people picker contains account again which was assigned in page load. In this case you have to put your code of assigin value inside If condition of !IsPostBack so that this piece of code executed only on first time page load and not in post back.
  2. Is your update button inside ajax update panel ? Do whole page postback or just fraction of page ? If update panel is used you have to put your people picker control also inside Ajax Update Panel.
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى sharepoint.stackexchange
scroll top