public static TagBuilder GenerateTagSpanRequired(string requiredSymbol, string requiredMessage, string requiredClass) { if (requiredSymbol == null) { requiredSymbol = "*"; } if (requiredMessage == null) { requiredMessage = "Esse campo é obrigatório!"; } if (requiredClass == null) { requiredClass = "req editor-field-required"; } TagBuilder tagSpan = null; tagSpan = new TagBuilder("sup"); tagSpan.AddCssClass(requiredClass); tagSpan.AddInputAttributeStaticValue("style", "color:red"); tagSpan.AddInputAttributeStaticValue("title", requiredMessage); tagSpan.InnerHtml = requiredSymbol; return(tagSpan); }
public override MvcHtmlString GenerateElementMvcString(TagRenderMode renderMode) { /*Criando os options...*/ string options = ""; TagBuilder option; foreach (SelectListItem item in this.selectListItems) { option = new TagBuilder("input"); option.AddInputAttributeStaticValue("type", "radio"); option.AddInputAttributeStaticValue("name", this.ComponentBase.SanitizedId); if (this.Value != null && (item.Value.ToString().Trim() == this.Value.ToString().Trim())) { option.MergeAttribute("checked", null); } option.MergeAttribute("value", item.Value.ToString()); option.MergeAttribute("data-value", item.Value.ToString()); if (item.Disabled) { option.MergeAttribute("disabled", null); } option.SetInnerText($" {item.Text}"); options += option.ToString(TagRenderMode.Normal) + "\n"; } TagElement.InnerHtml = options; return(TagElement.ToMvcHtmlString(TagRenderMode.Normal)); }
public static void AddInputTypeAttribute(this TagBuilder tagInput, Type fieldType) { if (fieldType == null) { return; } if (fieldType.Equals(new Boolean().GetType())) { tagInput.AddInputAttributeStaticValue("type", "checkbox"); } else if (fieldType.Equals(new int().GetType())) { tagInput.AddInputAttributeStaticValue("type", "number"); } else { tagInput.AddInputAttributeStaticValue("type", "text"); } }
public static TagBuilder GenerateTagDisplay(string id, string caption, RouteValueDictionary htmlAttributes, string tooltip = null, bool isRequired = false, string requiredSymbol = null, string requiredMessage = null, string requiredClass = null) { TagBuilder tagSpan = isRequired ? GenerateTagSpanRequired(requiredSymbol, requiredMessage, requiredClass) : null; TagBuilder tagLabel = new TagBuilder("span"); tagLabel.AddInputAttributeIsNotNullAndExpressionIsTrue("id", id, id != null); tagLabel.AddInputAttributeHtmlAttributes("class", htmlAttributes); tagLabel.AddInputAttributeHtmlAttributes("style", htmlAttributes); if (tooltip != null && !string.IsNullOrEmpty(tooltip)) { tagLabel.AddInputAttributeStaticValue("data-toggle", "tooltip"); tagLabel.AddInputAttributeStaticValue("data-placement", "top"); tagLabel.AddInputAttributeIsNotNullAndExpressionIsTrue("data-original-title", tooltip, tooltip != null); } tagLabel.InnerHtml = caption + (tagSpan != null ? tagSpan.ToMvcHtmlString(TagRenderMode.Normal).ToString() : ""); return(tagLabel); }
public static TagBuilder GenerateTagEditor(string id, string text, RouteValueDictionary htmlAttributes, string tooltip = null, bool isRequired = false, bool disabled = false) { TagBuilder tagEdit = new TagBuilder("input"); tagEdit.AddInputAttributeStaticValue("type", "text"); tagEdit.AddInputAttributeIsNotNullAndExpressionIsTrue("id", id, id != null); tagEdit.AddInputAttributeHtmlAttributes("class", htmlAttributes); tagEdit.AddInputAttributeHtmlAttributes("style", htmlAttributes); tagEdit.AddInputAttributeIfExpressionIsTrue("required", null, isRequired); tagEdit.AddInputAttributeIfExpressionIsTrue("disabled", null, disabled); if (tooltip != null && !string.IsNullOrEmpty(tooltip)) { tagEdit.AddInputAttributeStaticValue("data-toggle", "tooltip"); tagEdit.AddInputAttributeStaticValue("data-placement", "top"); tagEdit.AddInputAttributeIsNotNullAndExpressionIsTrue("data-original-title", tooltip, tooltip != null); } tagEdit.AddInputAttributeStaticValue("value", text); return(tagEdit); }
public static TagBuilder GenerateTagProgress(string id, string caption, RouteValueDictionary htmlAttributes, double?value = null, double?maxValue = null, string tooltip = null, bool isRequired = false, bool disabled = false) { TagBuilder tagEdit = new TagBuilder("progress"); tagEdit.AddInputAttributeIsNotNullAndExpressionIsTrue("id", id, id != null); tagEdit.AddInputAttributeHtmlAttributes("class", htmlAttributes); tagEdit.AddInputAttributeHtmlAttributes("style", htmlAttributes); tagEdit.AddInputAttributeIfExpressionIsTrue("required", null, isRequired); tagEdit.AddInputAttributeIfExpressionIsTrue("disabled", null, disabled); if (tooltip != null && !string.IsNullOrEmpty(tooltip)) { tagEdit.AddInputAttributeStaticValue("data-toggle", "tooltip"); tagEdit.AddInputAttributeStaticValue("data-placement", "top"); tagEdit.AddInputAttributeIsNotNullAndExpressionIsTrue("data-original-title", tooltip, tooltip != null); } /* Injetando o Valor no Input... */ tagEdit.AddInputAttributeIsNotNullAndExpressionIsTrue("max", maxValue, maxValue != null); tagEdit.AddInputAttributeIsNotNullAndExpressionIsTrue("value", value, value != null); return(tagEdit); //return new TagBuilder_Progress<TModel, TProperty>(dynamicComponentBase).GenerateElementMvcString(TagRenderMode.Normal); }