/// <summary>
        /// BuildLabel creates the label part of the Control.
        /// </summary>
        /// <param name="editInfo">The EditorInfo object for this control.</param>
        private PropertyLabelControl BuildLabel(EditorInfo editInfo)
        {
            var propLabel = new PropertyLabelControl {
                ID = editInfo.Name + "_Label"
            };

            propLabel.HelpStyle.CopyFrom(this.HelpStyle);
            propLabel.LabelStyle.CopyFrom(this.LabelStyle);
            var strValue = editInfo.Value as string;

            switch (this.HelpDisplayMode)
            {
            case HelpDisplayMode.Always:
                propLabel.ShowHelp = true;
                break;

            case HelpDisplayMode.EditOnly:
                if (editInfo.EditMode == PropertyEditorMode.Edit || (editInfo.Required && string.IsNullOrEmpty(strValue)))
                {
                    propLabel.ShowHelp = true;
                }
                else
                {
                    propLabel.ShowHelp = false;
                }

                break;

            case HelpDisplayMode.Never:
                propLabel.ShowHelp = false;
                break;
            }

            propLabel.Caption     = editInfo.Name;
            propLabel.HelpText    = editInfo.Name;
            propLabel.ResourceKey = editInfo.ResourceKey;
            if (editInfo.LabelMode == LabelMode.Left || editInfo.LabelMode == LabelMode.Right)
            {
                propLabel.Width = this.LabelWidth;
            }

            return(propLabel);
        }
		/// <summary>
		/// BuildLabel creates the label part of the Control
		/// </summary>
		/// <param name="editInfo">The EditorInfo object for this control</param>
		/// <history>
		///     [cnurse]	05/08/2006	created
		/// </history>
		private PropertyLabelControl BuildLabel(EditorInfo editInfo)
		{
			var propLabel = new PropertyLabelControl {ID = editInfo.Name + "_Label"};
		    propLabel.HelpStyle.CopyFrom(HelpStyle);
			propLabel.LabelStyle.CopyFrom(LabelStyle);
			var strValue = editInfo.Value as string;
			switch (HelpDisplayMode)
			{
				case HelpDisplayMode.Always:
					propLabel.ShowHelp = true;
					break;
				case HelpDisplayMode.EditOnly:
					if (editInfo.EditMode == PropertyEditorMode.Edit || (editInfo.Required && string.IsNullOrEmpty(strValue)))
					{
						propLabel.ShowHelp = true;
					}
					else
					{
						propLabel.ShowHelp = false;
					}
					break;
				case HelpDisplayMode.Never:
					propLabel.ShowHelp = false;
					break;
			}
			propLabel.Caption = editInfo.Name;
			propLabel.HelpText = editInfo.Name;
			propLabel.ResourceKey = editInfo.ResourceKey;
			if (editInfo.LabelMode == LabelMode.Left || editInfo.LabelMode == LabelMode.Right)
			{
				propLabel.Width = LabelWidth;
			}
			return propLabel;
		}
		/// <summary>
		/// BuildDiv creates the Control as a Div
		/// </summary>
		/// <param name="editInfo">The EditorInfo object for this control</param>
		/// <history>
		///     [cnurse]	05/08/2006	created
		/// </history>
		private void BuildDiv(EditorInfo editInfo)
		{
			var propLabel = new PropertyLabelControl();

			var propEditor = BuildEditor(editInfo);
			var visibility = BuildVisibility(editInfo);

			if (editInfo.LabelMode != LabelMode.None)
			{
				propLabel = BuildLabel(editInfo);
				propLabel.EditControl = propEditor;
			}

			var strValue = editInfo.Value as string; 
			if (ShowRequired && editInfo.Required && (editInfo.EditMode == PropertyEditorMode.Edit || (editInfo.Required && string.IsNullOrEmpty(strValue))))
			{
                propLabel.Required = true;
			}

			if (editInfo.LabelMode == LabelMode.Left || editInfo.LabelMode == LabelMode.Top)
			{
				Controls.Add(propLabel);
				Controls.Add(propEditor);
				if (visibility != null)
				{
					Controls.Add(visibility);
				}
			}
			else
			{
				Controls.Add(propEditor);
				if (visibility != null)
				{
					Controls.Add(visibility);
				}
				if ((propLabel != null))
				{
					Controls.Add(propLabel);
				}
			}
			
			//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 = Width;
					Controls.Add(validator);
				}
			}
		}
        /// <summary>
        /// This method will build a dnn property label (Same as used in the user profile edit area) that can be added to a control.
        /// </summary>
        /// <param name="resourceKey"></param>
        /// <returns></returns>
        /// <remarks></remarks>
        private PropertyLabelControl BuildLabel(string resourceKey)
        {
            var propLabel = new PropertyLabelControl { ID = resourceKey + "_Label", ShowHelp = true, ResourceKey = resourceKey };

            return propLabel;
        }
		/// <summary>
		/// This method will build a dnn property label (Same as used in the user profile edit area) that can be added to a control.
		/// </summary>
		/// <param name="resourceKey"></param>
		/// <returns></returns>
		/// <remarks></remarks>
		private PropertyLabelControl BuildLabel(string resourceKey)
		{
			var propLabel = new PropertyLabelControl();
			propLabel.ID = resourceKey + "_Label";
			propLabel.ShowHelp = true;
			propLabel.ResourceKey = resourceKey;

			return propLabel;
		}
        /// <Summary>BuildLabel creates the label part of the Control</Summary>
        /// <Param name="editInfo">The EditorInfo object for this control</Param>
        private PropertyLabelControl BuildLabel( EditorInfo editInfo )
        {
            PropertyLabelControl propLabel = new PropertyLabelControl();
            propLabel.ID = editInfo.Name + "_Label";
            propLabel.HelpStyle.CopyFrom(HelpStyle);
            propLabel.LabelStyle.CopyFrom(LabelStyle);
            string strValue = editInfo.Value as string;
            if (editInfo.EditMode == PropertyEditorMode.Edit | (editInfo.Required & string.IsNullOrEmpty(strValue)))
            {
                propLabel.ShowHelp = true;
            }
            else
            {
                propLabel.ShowHelp = false;
            }
            propLabel.Caption = editInfo.Name;
            propLabel.HelpText = editInfo.Name;
            propLabel.ResourceKey = editInfo.ResourceKey;
            if (editInfo.LabelMode == LabelMode.Left || editInfo.LabelMode == LabelMode.Right)
            {
                propLabel.Width = LabelWidth;
            }

            return propLabel;
        }
示例#7
0
        Control GetLabel(string title, string help, Control  editcontrol)
        {

            if (help == string.Empty)
            {
                var l = new Label
                {
                    Text = string.Format("<span>{0}</span>", title),
                    AssociatedControlID = editcontrol.ID
                };

                var d = new HtmlGenericControl("div");
                d.Attributes.Add("class", "dnnFormLabelWithoutHelp");
                d.Controls.Add(l);

                _labelcontrols.Add(l, editcontrol);
                return d;
            }
            var label = new PropertyLabelControl
                            {
                                ID = string.Format("{0}_label", XmlConvert.EncodeName(title)),
                                Caption = title,
                                HelpText = help,
                                EditControl = editcontrol,
                            };
            _propertylabelcontrols.Add(label, editcontrol);
            return label;
        }