如何在编辑表单上编辑DropDownChoiceField查找字段列表的属性?

时间:2013-09-30 12:13:31

标签: c# javascript .net sharepoint sharepoint-2010

我有两种类型的查找列表字段。当用户更改第一个字段时,如何动态更改第二个字段的值?这是我的绑定代码(用于编辑项目表单的Web部件代码):

protected override void OnPreRender(EventArgs e)
    {
        SPFormContext fc = SPContext.Current.FormContext;

        foreach (BaseFieldControl bfc in fc.FieldControlCollection)
        {
            if (bfc.FieldName == "type12")
            {
                DropDownList ddl = FindControlRecursive(bfc, "Lookup") as DropDownList;
                if (ddl != null)
                    ddl.Attributes.Add("onchange", "javascript:alert('Test')");
            }
        }
    }


    public static Control FindControlRecursive(Control root, string id)
    {
        if (root.ID == id)
            return root;

        foreach (Control c in root.Controls)
        {
            Control t = FindControlRecursive(c, id);
            if (t != null)
                return t;
        }

        return null;
    }

0 个答案:

没有答案