/// <summary> /// BuildEditor creates the editor part of the Control. /// </summary> /// <param name="editInfo">The EditorInfo object for this control.</param> private EditControl BuildEditor(EditorInfo editInfo) { EditControl propEditor = EditControlFactory.CreateEditControl(editInfo); propEditor.ViewStateMode = ViewStateMode.Enabled; propEditor.ControlStyle.CopyFrom(this.EditControlStyle); propEditor.LocalResourceFile = this.LocalResourceFile; propEditor.User = this.User; if (editInfo.ControlStyle != null) { propEditor.ControlStyle.CopyFrom(editInfo.ControlStyle); } propEditor.ItemAdded += this.CollectionItemAdded; propEditor.ItemDeleted += this.CollectionItemDeleted; propEditor.ValueChanged += this.ValueChanged; if (propEditor is DNNListEditControl) { var listEditor = (DNNListEditControl)propEditor; listEditor.ItemChanged += this.ListItemChanged; } this.Editor = propEditor; return(propEditor); }
private static EditControl CreateEditControlInternal(string systemType) { EditControl propEditor = null; try { var type = Type.GetType(systemType); if (type != null) { switch (type.FullName) { case "System.DateTime": propEditor = new DateTimeEditControl(); break; case "System.Boolean": propEditor = new CheckEditControl(); break; case "System.Int32": case "System.Int16": propEditor = new IntegerEditControl(); break; default: if (type.IsEnum) { propEditor = new EnumEditControl(systemType); } break; } } } catch (Exception) { // ignore } return(propEditor ?? new TextEditControl(systemType)); }
/// <Summary>BuildEditor creates the editor part of the Control</Summary> /// <Param name="editInfo">The EditorInfo object for this control</Param> private EditControl BuildEditor(EditorInfo editInfo) { EditControl propEditor = EditControlFactory.CreateEditControl(editInfo); propEditor.ControlStyle.CopyFrom(EditControlStyle); propEditor.LocalResourceFile = LocalResourceFile; if (editInfo.ControlStyle != null) { propEditor.ControlStyle.CopyFrom(editInfo.ControlStyle); } propEditor.ValueChanged += new PropertyChangedEventHandler(this.ValueChanged); if (propEditor is DNNListEditControl) { DNNListEditControl listEditor = (DNNListEditControl)propEditor; listEditor.ItemChanged += new PropertyChangedEventHandler(this.ListItemChanged); } _Editor = propEditor; return(propEditor); }
protected override WebControl CreateControlInternal(Control container) { control = Reflection.CreateObject(ControlType, ControlType) as EditControl; if (control != null) { control.ID = ID + "_Control"; control.Name = ID; control.EditMode = PropertyEditorMode.Edit; control.Required = false; control.Value = Value; control.OldValue = Value; control.ValueChanged += ValueChanged; control.CssClass = "dnnFormInput"; container.Controls.Add(control); } return control; }
/// ----------------------------------------------------------------------------- /// <summary> /// BuildTable creates the Control as a Table /// </summary> /// <param name="editInfo">The EditorInfo object for this control</param> /// ----------------------------------------------------------------------------- private void BuildTable(EditorInfo editInfo) { var tbl = new Table(); var labelCell = new TableCell(); var editorCell = new TableCell(); //Build Label Cell labelCell.VerticalAlign = VerticalAlign.Top; labelCell.Controls.Add(BuildLabel(editInfo)); if (editInfo.LabelMode == LabelMode.Left || editInfo.LabelMode == LabelMode.Right) { labelCell.Width = LabelWidth; } //Build Editor Cell editorCell.VerticalAlign = VerticalAlign.Top; EditControl propEditor = BuildEditor(editInfo); Image requiredIcon = BuildRequiredIcon(editInfo); editorCell.Controls.Add(propEditor); if (requiredIcon != null) { editorCell.Controls.Add(requiredIcon); } if (editInfo.LabelMode == LabelMode.Left || editInfo.LabelMode == LabelMode.Right) { editorCell.Width = EditControlWidth; } VisibilityControl visibility = BuildVisibility(editInfo); if (visibility != null) { editorCell.Controls.Add(new LiteralControl(" ")); editorCell.Controls.Add(visibility); } //Add cells to table var editorRow = new TableRow(); var labelRow = new TableRow(); if (editInfo.LabelMode == LabelMode.Bottom || editInfo.LabelMode == LabelMode.Top || editInfo.LabelMode == LabelMode.None) { editorCell.ColumnSpan = 2; editorRow.Cells.Add(editorCell); if (editInfo.LabelMode == LabelMode.Bottom || editInfo.LabelMode == LabelMode.Top) { labelCell.ColumnSpan = 2; labelRow.Cells.Add(labelCell); } if (editInfo.LabelMode == LabelMode.Top) { tbl.Rows.Add(labelRow); } tbl.Rows.Add(editorRow); if (editInfo.LabelMode == LabelMode.Bottom) { tbl.Rows.Add(labelRow); } } else if (editInfo.LabelMode == LabelMode.Left) { editorRow.Cells.Add(labelCell); editorRow.Cells.Add(editorCell); tbl.Rows.Add(editorRow); } else if (editInfo.LabelMode == LabelMode.Right) { editorRow.Cells.Add(editorCell); editorRow.Cells.Add(labelCell); tbl.Rows.Add(editorRow); } //Build the Validators BuildValidators(editInfo, propEditor.ID); var validatorsRow = new TableRow(); var validatorsCell = new TableCell(); validatorsCell.ColumnSpan = 2; //Add the Validators to the editor cell foreach (BaseValidator validator in Validators) { validatorsCell.Controls.Add(validator); } validatorsRow.Cells.Add(validatorsCell); tbl.Rows.Add(validatorsRow); //Add the Table to the Controls Collection Controls.Add(tbl); }
/// <Summary>BuildDiv creates the Control as a Div</Summary> /// <Param name="editInfo">The EditorInfo object for this control</Param> private void BuildDiv(EditorInfo editInfo) { HtmlGenericControl divLabel = null; if (editInfo.LabelMode != LabelMode.None) { divLabel = new HtmlGenericControl("div"); string style = "float: " + editInfo.LabelMode.ToString().ToLower(); if (editInfo.LabelMode == LabelMode.Left || editInfo.LabelMode == LabelMode.Right) { style += "; width: " + LabelWidth.ToString(); } divLabel.Attributes.Add("style", style); divLabel.Controls.Add(BuildLabel(editInfo)); } HtmlGenericControl divEdit = new HtmlGenericControl("div"); string side = GetOppositeSide(editInfo.LabelMode); // HACK : Modified to not error if object is null. //if (side.Length > 0) if (!String.IsNullOrEmpty(side)) { string style = "float: " + side; style += "; width: " + EditControlWidth.ToString(); divEdit.Attributes.Add("style", style); } EditControl propEditor = BuildEditor(editInfo); VisibilityControl visibility = BuildVisibility(editInfo); if (visibility != null) { visibility.Attributes.Add("style", "float: right;"); divEdit.Controls.Add(visibility); } divEdit.Controls.Add(propEditor); Image requiredIcon = BuildRequiredIcon(editInfo); divEdit.Controls.Add(propEditor); if (requiredIcon != null) { divEdit.Controls.Add(requiredIcon); } if (editInfo.LabelMode == LabelMode.Left || editInfo.LabelMode == LabelMode.Top) { Controls.Add(divLabel); Controls.Add(divEdit); } else { Controls.Add(divEdit); if (divLabel != null) { Controls.Add(divLabel); } } //Build the Validators BuildValidators(editInfo, propEditor.ID); if (Validators.Count > 0) { //Add the Validators to the editor cell foreach (BaseValidator validator in Validators) { validator.Width = this.Width; Controls.Add(validator); } } }
/// <Summary>BuildEditor creates the editor part of the Control</Summary> /// <Param name="editInfo">The EditorInfo object for this control</Param> private EditControl BuildEditor( EditorInfo editInfo ) { EditControl propEditor = EditControlFactory.CreateEditControl(editInfo); propEditor.ControlStyle.CopyFrom(EditControlStyle); propEditor.LocalResourceFile = LocalResourceFile; if (editInfo.ControlStyle != null) { propEditor.ControlStyle.CopyFrom(editInfo.ControlStyle); } propEditor.ValueChanged += new PropertyChangedEventHandler(this.ValueChanged); if (propEditor is DNNListEditControl) { DNNListEditControl listEditor = (DNNListEditControl)propEditor; listEditor.ItemChanged += new PropertyChangedEventHandler(this.ListItemChanged); } _Editor = propEditor; return propEditor; }