public Button(string text, ButtonSettings settings = null, object htmlAttributes = null) : base("a", text, false) { _settings = settings ?? new ButtonSettings(); Attrs = new HtmlAttributes(htmlAttributes); Attrs["class"] += "btn"; Attrs["class"] += "btn-" + _settings.Category.ToString().ToLower(); if (_settings.Size != Size.Md) { Attrs["class"] += "btn-" + _settings.Size.ToString().ToLower(); } if (_settings.BlockLevel) { Attrs["class"] += "btn-block"; } if (!string.IsNullOrEmpty(_settings.LinkUrl)) { Attrs["href"] = _settings.LinkUrl; _settings.Tag = ButtonSettings.ButtonTag.A; } if (_settings.Tag == ButtonSettings.ButtonTag.A && string.IsNullOrEmpty(_settings.LinkUrl)) { Attrs["href"] = "#"; } if (_settings.IsDisabled) { Attrs[_settings.Tag == ButtonSettings.ButtonTag.A ? "class" : "disabled"] += "disabled"; } HtmlTag = _settings.Tag.ToString().ToLower(); }
public Button(string text, ButtonSettings settings = null, object htmlAttributes = null) : base("a", text, false) { _settings = settings ?? new ButtonSettings(); Attrs = new HtmlAttributes(htmlAttributes); Attrs["class"] += "btn"; Attrs["class"] += "btn-" + _settings.Category.ToString().ToLower(); if (_settings.Size != Size.Md) Attrs["class"] += "btn-" + _settings.Size.ToString().ToLower(); if (_settings.BlockLevel) Attrs["class"] += "btn-block"; if (!string.IsNullOrEmpty(_settings.LinkUrl)) { Attrs["href"] = _settings.LinkUrl; _settings.Tag = ButtonSettings.ButtonTag.A; } if (_settings.Tag == ButtonSettings.ButtonTag.A && string.IsNullOrEmpty(_settings.LinkUrl)) Attrs["href"] = "#"; if (_settings.IsDisabled) Attrs[_settings.Tag == ButtonSettings.ButtonTag.A ? "class" : "disabled"] += "disabled"; HtmlTag = _settings.Tag.ToString().ToLower(); }
public Button Button(string text, ButtonSettings settings = null) { var button = new Button(text, settings); button.Attrs["class"] += "navbar-btn"; return button; }
public static Button Submit(this HtmlHelper html, string text = "Submit", ButtonSettings buttonSettings = null) { return new Button(text, buttonSettings, new{type="Submit"}); }
public static Button Button(this HtmlHelper html, string text, string url, ButtonSettings buttonSettings) { buttonSettings.LinkUrl = url; return new Button(text, buttonSettings); }
public static Button Button(this HtmlHelper html, string text, ButtonSettings buttonSettings) { return new Button(text, buttonSettings); }
public static Button Submit(this HtmlHelper html, string text = "Submit", ButtonSettings buttonSettings = null) { return(new Button(text, buttonSettings, new{ type = "Submit" })); }
public static Button Button(this HtmlHelper html, string text, string url, ButtonSettings buttonSettings) { buttonSettings.LinkUrl = url; return(new Button(text, buttonSettings)); }
public static Button Button(this HtmlHelper html, string text, ButtonSettings buttonSettings) { return(new Button(text, buttonSettings)); }