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));
        }
Esempio n. 2
0
        public override MvcHtmlString GenerateElementMvcString(TagRenderMode renderMode)
        {
            /*Criando os options...*/
            string options = "";

            TagBuilder option;

            if (this.optionLabel != null)
            {
                option = new TagBuilder("option");
                option.SetInnerText(this.optionLabel.Text);
                options += option.ToString(TagRenderMode.Normal) + "\n";
            }

            foreach (SelectListItem item in this.selectListItems)
            {
                option = new TagBuilder("option");
                if (this.Value != null && (item.Value.ToString().Trim() == this.Value.ToString().Trim()))
                {
                    option.MergeAttribute("selected", 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 override MvcHtmlString GenerateElementMvcString(TagRenderMode renderMode)
 {
     return(TagElement.ToMvcHtmlString(renderMode));
 }