Sharepoint People Editor控制在回发时丢失值 [英] Sharepoint People Editor Control losing values on postback

查看:80
本文介绍了Sharepoint People Editor控制在回发时丢失值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我创建了一个应用程序页面,其中我使用的是Sharepoint People Editor控件和一个按钮控件。人员编辑器控件在页面加载时自动填充,并根据用户权限启用或禁用控件。

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.

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;
        }



当用户访问此页面时,如果他是有效用户,则启用人员编辑器控件,他可以在其中添加更多人他点击了按钮,我可以从 PeopleEditor1.CommaSeparatedAccount 中读取新值。



这里的问题是,如果用户未经过身份验证,则人员编辑器控件将被禁用,以便他无法添加新成员,并且当他单击按钮时, PeopleEditor1.CommaSeparatedAccounts 只是一个空字符串。控件中缺少页面加载的预填充值。我已经尝试了 PeopleEditor1.EnableViewState PeopleEditor1.ViewStateMode 的所有组合来读取预先填充的值禁用控制,但没有成功。



除了人物编辑器外,还有一些asp.net文本框和下拉列表在页面加载期间预先填充,并且是根据用户权限启用/禁用(为了代码可读性,我已将其删除)。这些都没有造成问题。只有人民编辑,我才面临这样的问题。



有谁能帮助我让我知道问题可能是什么以及解决方法是什么?我不想改变逻辑,因为许多其他控件依赖于它并且工作正常。谷歌尝试了它,但没有任何好的信息。感谢任何帮助。



提前致谢。

RO ..


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..

推荐答案

尝试在

之后添加PeopleEditor1.Validate()PeopleEditor1.CommaSeparatedAccounts =" MYDOMAIN\\ user1,MYDOMAIN\\ user2;"
try to add PeopleEditor1.Validate() after
PeopleEditor1.CommaSeparatedAccounts ="MYDOMAIN\\user1,MYDOMAIN\\user2;"


这篇关于Sharepoint People Editor控制在回发时丢失值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆