Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I've created an application page in which I'm using a Sharepoint People Editor control and a button control. The people editor control is autopopulated on the page load and the control is enabled or disabled based on the user permissions.
C#
protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                PeopleEditor1.CommaSeparatedAccounts = "MYDOMAIN\\user1,MYDOMAIN\\user2;";
                bool IsAuthenticated = ValidateUser(); // ValidateUser() is a function which returns true or false based on logged in user permissions. Logic working fine for this function
                if (IsAuthenticated)
                    PeopleEditor1.Enabled = true;
                else PeopleEditor1.Enabled = false;
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string commaccs = PeopleEditor1.CommaSeparatedAccounts;
        }

When the user visits this page, if he is a valid user, the people editor control is enabled, he can add more people into it and when he clicks the button, I'm able to read the new values from the PeopleEditor1.CommaSeparatedAccounts.

The problem here is that, if the user is not authenticated, the people editor control is disable, so that he cannot add new members, and when he clicks the button, PeopleEditor1.CommaSeparatedAccounts is just an empty string. The pre-populated values on the page load is missing from the control. I've tried all the combinations for PeopleEditor1.EnableViewState and PeopleEditor1.ViewStateMode to read the pre-populated values from the disabled control, but without success.

Apart from the people editor, there are some asp.net textboxes and dropdown lists which are pre-populated during page load, and are enabled/disabled based on user permissions (For code readability, I've removed them above). None of these are causing problems. Only with the people editor, I'm facing such problem.

Could anyone please help me in letting know what the problem could be and what would be the workaround for this? I wouldn't like to change the logic as many other controls are dependent on it and are working fine. Tried Google around it but without any great information. Any help is appreciated.

Thanks in advance.
RO..
Posted
Updated 10-Aug-10 3:33am
v2

1 solution

try to add PeopleEditor1.Validate() after
PeopleEditor1.CommaSeparatedAccounts ="MYDOMAIN\\user1,MYDOMAIN\\user2;"
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900