Esempio n. 1
0
        private static void SetButtonOptions(ButtonOptions options, HtmlBuilder builder)
        {
            Dictionary <string, object> dict = new Dictionary <string, object>();

            dict.Add("plain", ClientHelper.GetBool(options.Plain));
            if (!string.IsNullOrWhiteSpace(options.Icon))
            {
                dict.Add("iconCls", "icon-" + options.Icon);
            }
            if (dict.Count > 0)
            {
                builder.AddAttribute("data-options", DictHelper.ToJsonItem(dict));
            }
            if (!string.IsNullOrEmpty(options.Target))
            {
                builder.AddAttribute("target", options.Target);
            }
            if (!string.IsNullOrEmpty(options.Href))
            {
                builder.AddAttribute("href", options.Href);
            }
            if (!string.IsNullOrEmpty(options.OnClick))
            {
                builder.AddAttribute("onclick", options.OnClick);
            }
            if (!string.IsNullOrEmpty(options.ID))
            {
                builder.AddAttribute("id", options.ID);
            }
        }
Esempio n. 2
0
        private static HtmlBuilder GetButtonBuilder(string text, ButtonOptions options)
        {
            HtmlBuilder tag = new HtmlBuilder("a")
            {
                InnerHtml = text
            };

            tag.AddClass("easyui-linkbutton");
            SetButtonOptions(options, tag);
            return(tag);
        }
Esempio n. 3
0
        public static MvcHtmlString Button(this HtmlHelper helper, string text, Action <ButtonOptions> action)
        {
            ButtonOptions options = new ButtonOptions();

            if (action != null)
            {
                action(options);
            }
            HtmlBuilder tag = GetButtonBuilder(text, options);

            return(MvcHtmlString.Create(tag.ToString()));
        }
Esempio n. 4
0
 public static MvcHtmlString Button(this HtmlHelper helper, string text, ButtonOptions options)
 {
     return(MvcHtmlString.Create(GetButtonBuilder(text, options).ToString()));
 }