public override string ToHtmlString() { BtnStyles style = BtnStyle; this.Aria("disabled", "false"); this.AddClass("btn"); this.AddClassWhen(style.HasFlag(BtnStyles.Default), "btn-default"); this.AddClassWhen(style.HasFlag(BtnStyles.Large), "btn-large"); this.AddClassWhen(style.HasFlag(BtnStyles.Small), "btn-small"); this.AddClassWhen(style.HasFlag(BtnStyles.Xs), "btn-xs"); this.AddClassWhen(style.HasFlag(BtnStyles.Primary), "btn-primary"); this.AddClassWhen(style.HasFlag(BtnStyles.Success), "btn-success"); this.AddClassWhen(style.HasFlag(BtnStyles.Info), "btn-info"); this.AddClassWhen(style.HasFlag(BtnStyles.Danger), "btn-danger"); this.AddClassWhen(style.HasFlag(BtnStyles.Warning), "btn-warning"); this.AddClassWhen(style.HasFlag(BtnStyles.Link), "btn-link"); this.AddClassWhen(style.HasFlag(BtnStyles.Block), "btn-block"); this.AddClassWhen(style.HasFlag(BtnStyles.Active), "active"); this.BuildWhen(style.HasFlag(BtnStyles.Disabled), x => { x.Attr("disabled", "disabled"); x.AddClass("disabled"); x.Aria("disabled", "true"); }); this.DefaultAttr("aria-role", "button"); this.DefaultProp("tagName", "button"); var tagName = this.Prop <string>("tagName"); if (tagName.Equals("a", StringComparison.CurrentCultureIgnoreCase)) { this.DefaultAttr("href", "#"); } else { this.DefaultAttr("type", "button"); } if (DropDownToggle) { this.AddClass("dropdown-toggle"); this.DefaultAttr("data-toggle", "dropdown"); } var tagBuilder = new TagBuilder(tagName) { InnerHtml = BuildInnerHtml() }; tagBuilder.MergeAttributes(HtmlAttributes, true); return(tagBuilder.ToString(TagRenderMode.Normal)); }
/// <summary> /// </summary> public static IBtnBuilder Style(this IBtnBuilder builder, BtnStyles style) { return(builder.Prop("__btnStyle", style | builder.Prop <BtnStyles>("__btnStyle"))); }