/// <summary>
    /// Adds contact's custom fields to the dialog.
    /// </summary>
    /// <param name="fields">Array list with custom fields (FormFieldInfo)</param>
    protected void AddCustomFields(IEnumerable <IDataDefinitionItem> fields)
    {
        CMSModules_AdminControls_Controls_Class_ClassFields fieldControl = null;

        // Initialize hashtable that will store controls for custom fields
        customControls = new Hashtable();

        // Add form to the placeholder 'Custom'
        Panel form = new Panel {
            CssClass = "form-horizontal"
        };

        plcCustom.Controls.Add(form);

        FormFieldInfo field;

        foreach (IDataDefinitionItem item in fields)
        {
            if (!(item is FormFieldInfo))
            {
                continue;
            }
            field = item as FormFieldInfo;

            Panel formGroup = new Panel {
                CssClass = "form-group"
            };
            form.Controls.Add(formGroup);

            // Create label div
            Panel labelPanel = new Panel {
                CssClass = "editing-form-label-cell"
            };
            formGroup.Controls.Add(labelPanel);

            // Create label
            LocalizedLabel label = new LocalizedLabel();
            label.Text            = ResHelper.LocalizeString(field.GetDisplayName(MacroContext.CurrentResolver));
            label.EnableViewState = false;
            label.DisplayColon    = true;
            label.CssClass        = "control-label";
            labelPanel.Controls.Add(label);

            // Create value div
            Panel valuePanel = new Panel {
                CssClass = "editing-form-value-cell"
            };
            formGroup.Controls.Add(valuePanel);

            // Create control
            fieldControl               = (CMSModules_AdminControls_Controls_Class_ClassFields)Page.LoadUserControl("~/CMSModules/AdminControls/Controls/Class/ClassFields.ascx");
            fieldControl.ID            = "fld" + field.Name;
            fieldControl.ClassName     = ClassName;
            fieldControl.FieldDataType = field.DataType;
            valuePanel.Controls.Add(fieldControl);

            // Store the control to hashtable
            customControls.Add(field.Name, fieldControl);
        }
    }
コード例 #2
0
    /// <summary>
    /// Adds contact's custom fields to the dialog.
    /// </summary>
    /// <param name="fields">Array list with custom fields (FormFieldInfo)</param>
    protected void AddCustomFields(IEnumerable <IFormItem> fields)
    {
        TableRow       tabRow  = null;
        TableCell      tabCell = null;
        LocalizedLabel label   = null;
        CMSModules_AdminControls_Controls_Class_ClassFields fieldControl = null;

        // Initialize hashtable that will store controls for custom fields
        customControls = new Hashtable();

        // Add table to the placeholder 'Custom'
        Table table = new Table();

        plcCustom.Controls.Add(table);

        int           i      = 0;
        bool          newRow = true;
        FormFieldInfo field;

        foreach (IFormItem item in fields)
        {
            if (!(item is FormFieldInfo))
            {
                continue;
            }
            field = item as FormFieldInfo;

            newRow = (i % 2) == 0;
            // Create new row - each row contains two controls
            if (newRow)
            {
                tabRow = new TableRow();
                table.Rows.Add(tabRow);
            }

            // Create lable cell
            tabCell          = new TableCell();
            tabCell.CssClass = "ContactLabel";
            tabRow.Cells.Add(tabCell);

            // Create label
            label                 = new LocalizedLabel();
            label.Text            = ResHelper.LocalizeString(field.Caption);
            label.EnableViewState = false;
            label.DisplayColon    = true;
            tabCell.Controls.Add(label);

            // Create control cell
            tabCell = new TableCell();
            if (newRow)
            {
                tabCell.CssClass = "ContactControl";
            }
            else
            {
                tabCell.CssClass = "ContactControlRight";
            }
            tabRow.Cells.Add(tabCell);

            // Create control
            fieldControl               = (CMSModules_AdminControls_Controls_Class_ClassFields)Page.LoadUserControl("~/CMSModules/AdminControls/Controls/Class/ClassFields.ascx");
            fieldControl.ID            = "fld" + field.Name;
            fieldControl.ClassName     = ClassName;
            fieldControl.FieldDataType = field.DataType;
            tabCell.Controls.Add(fieldControl);

            // Store the control to hashtable
            customControls.Add(field.Name, fieldControl);

            i++;
        }
    }