예제 #1
0
        /// <inheritdoc />
        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            if (string.IsNullOrEmpty(Action))
            {
                throw new MissingRequiredAttribute("Action", Action);
            }

            writer.AddAttribute("action", Action);

            if (Width > 0)
            {
                writer.AddAttribute("width", Width.ToString());
            }
            if (LabelWidth > 0)
            {
                writer.AddAttribute("labelwidth", LabelWidth.ToString());
            }

            base.AddAttributesToRender(writer);
        }
예제 #2
0
        /// <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);
                }
            }
        }