public static MvcHtmlString Semantic_Button(this HtmlHelper helper, string id, string text, enButtonType btnType, Size size, object htmlAttributes = null) { StringBuilder sbHtml = new StringBuilder(); sbHtml.Append(" <button "); var arrType = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes).Where(w => w.Key.ToLower() == "type").ToList(); var arrClass = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes).Where(w => w.Key.ToLower() == "class").Select(s => s.Value).ToList();; string addClass = string.Empty; if (arrClass.Count() > 0) { addClass = string.Join(" ", arrClass); } if (arrType.Count > 0) { sbHtml.Append(arrType[0].Key).Append("='").Append(arrType[0].Value).Append("'"); } else { sbHtml.Append("type='button'"); } sbHtml.Append(" class='ui "); switch (btnType) { case enButtonType.Del: sbHtml.Append(" ").Append(SemanticUIHelper.enColor.red.ToString()).Append(" "); break; case enButtonType.Cancel: sbHtml.Append(" ").Append(SemanticUIHelper.enColor.orange.ToString()).Append(" "); break; case enButtonType.New: sbHtml.Append(" ").Append(SemanticUIHelper.enColor.teal.ToString()).Append(" "); break; case enButtonType.Request: sbHtml.Append(" ").Append(SemanticUIHelper.enColor.olive.ToString()).Append(" "); break; case enButtonType.Save: sbHtml.Append(" ").Append(SemanticUIHelper.enColor.blue.ToString()).Append(" "); break; case enButtonType.Excel: sbHtml.Append(" ").Append(SemanticUIHelper.enColor.green.ToString()).Append(" "); break; case enButtonType.ToList: sbHtml.Append(" ").Append(SemanticUIHelper.enColor.grey.ToString()).Append(" "); break; default: break; } sbHtml.Append(size.ToString()).Append(" button ").Append(addClass).Append("' id='").Append(id).Append("' name='").Append(id).Append("'").Append(SemanticUIHelper.GetHtmlAttributeString(htmlAttributes)).Append("> ").Append("\n"); sbHtml.Append(text).Append("\n"); sbHtml.Append(" </button>").Append("\n"); return(MvcHtmlString.Create(sbHtml.ToString().Trim())); }
public static MvcHtmlString Semantic_Button(this HtmlHelper helper, string id, string text, enButtonType btnType = enButtonType.Normal, object htmlAttributes = null) { return(Semantic_Button(helper, id, text, btnType, Size.mini, htmlAttributes)); }