protected override void BuildControl(System.Web.Mvc.TagBuilder builder, Products.CustomFieldDefinition field, string value, object htmlAttributes, System.Web.Mvc.ViewContext viewContext) { builder.AddCssClass("form-list"); var itemsHtml = new StringBuilder(); var i = 0; foreach (var item in field.SelectionItems) { itemsHtml.AppendLine("<li>"); var radioId = field.Name + "_" + i; var radio = new TagBuilder("input"); radio.MergeAttribute("id", radioId); radio.MergeAttribute("type", "radio"); radio.MergeAttribute("name", field.Name); radio.MergeAttribute("value", item.Value); var label = new TagBuilder("label"); label.InnerHtml = item.Text; label.AddCssClass("inline"); label.MergeAttribute("for", radioId); itemsHtml.AppendLine(radio.ToString(TagRenderMode.SelfClosing)); itemsHtml.AppendLine(label.ToString()); itemsHtml.AppendLine("</li>"); i++; } builder.InnerHtml = itemsHtml.ToString(); base.BuildControl(builder, field, value, htmlAttributes, viewContext); }
protected override void BuildControl(System.Web.Mvc.TagBuilder builder, EAV.CustomField field, string value, object htmlAttributes, System.Web.Mvc.ViewContext viewContext) { builder.AddCssClass("form-list"); if (!String.IsNullOrWhiteSpace(field.SelectionItems)) { var itemsHtml = new StringBuilder(); var items = JsonConvert.DeserializeObject<List<SelectionListItem>>(field.SelectionItems); for (var i = 0; i < items.Count; i++) { var item = items[i]; itemsHtml.AppendLine("<li>"); var radioId = field.Name + "_" + i; var radio = new TagBuilder("input"); radio.MergeAttribute("id", radioId); radio.MergeAttribute("type", "radio"); radio.MergeAttribute("name", field.Name); radio.MergeAttribute("value", item.Value); var label = new TagBuilder("label"); label.InnerHtml = item.Key; label.AddCssClass("inline"); label.MergeAttribute("for", radioId); itemsHtml.AppendLine(radio.ToString(TagRenderMode.SelfClosing)); itemsHtml.AppendLine(label.ToString()); itemsHtml.AppendLine("</li>"); } builder.InnerHtml = itemsHtml.ToString(); } base.BuildControl(builder, field, value, htmlAttributes, viewContext); }
private void ShowHideTab( bool show, System.Web.UI.HtmlControls.HtmlGenericControl control ) { if ( show ) { control.AddCssClass( "active" ); } else { control.RemoveCssClass( "active" ); } }