protected override void Render(System.Web.UI.HtmlTextWriter writer) { //setup a hotkey if present if (ButtonType == MenuButtonType.Primary && String.IsNullOrEmpty(Hotkey)) { Data.Add("hotkey", "ctrl+" + this.Text.ToLower()[0]); } else if (!string.IsNullOrEmpty(Hotkey)) { Data.Add("shortcut", Hotkey); } Data.AppendTo(this); string cssClass = "btn"; if (Icon != null) { cssClass = "btn editorIcon"; var i = Icon.Trim('.'); if (!string.IsNullOrEmpty(i)) { this.ToolTip = this.Text; if (i.Contains(".")) { this.Text = "<img src='" + IOHelper.ResolveUrl(Icon) + "' alt='" + this.ToolTip + "'/> " + this.ToolTip; } else { this.Text = "<i class='icon icon-" + Icon.Replace("icon-", "") + "'></i> " + this.ToolTip; } } } cssClass += " btn-" + Enum.GetName(ButtonType.GetType(), ButtonType).ToLower() + " " + CssClass; this.CssClass = cssClass.Trim(); base.Render(writer); }
public static string ToDescriptionString(this ButtonType val) { var attributes = (DescriptionAttribute[])val.GetType().GetField(val.ToString()).GetCustomAttributes(typeof(DescriptionAttribute), false); return(attributes.Length > 0 ? attributes[0].Description : string.Empty); }