示例#1
0
        private static MvcHtmlString WButtonHelper(string name, string href, string title, string icon, WButtonType type, bool submit, object htmlAttributes = null)
        {
            var dictionary = (IDictionary<string, object>)AnonymousObjectToHtmlAttributes(htmlAttributes);

            TagBuilder tagBuilder;

            if (href != null)
            {
                tagBuilder = new TagBuilder("a");
                tagBuilder.MergeAttribute("href", href);
            }
            else
            {
                tagBuilder = new TagBuilder("div");
            }

            tagBuilder.MergeAttributes(dictionary);

            if (name != null)
            {
                tagBuilder.MergeAttribute("id", name);
                tagBuilder.MergeAttribute("name", name);
            }

            tagBuilder.AddCssClass("wbutton");
            tagBuilder.InnerHtml = title;

            if (submit)
            {
                tagBuilder.AddCssClass("submit");
            }

            if (type == WButtonType.Alert)
            {
                tagBuilder.AddCssClass("wbutton-alert");
            }
            else if (type == WButtonType.Action)
            {
                tagBuilder.AddCssClass("wbutton-action");
            }
            else
            {
                tagBuilder.AddCssClass("wbutton-normal");
            }

            if (!String.IsNullOrEmpty(icon))
            {
                tagBuilder.MergeAttribute("icon", icon);
            }
            return new MvcHtmlString(tagBuilder.ToString());
        }
示例#2
0
 public static MvcHtmlString WLinkButton(this HtmlHelper html, string href, string title, string icon, WButtonType type, object htmlAttributes = null)
 {
     return WLinkButton(html, href, title, icon, type, false, htmlAttributes);
 }
示例#3
0
 public static MvcHtmlString WLinkButton(this HtmlHelper html, string href, string title, string icon, WButtonType type, bool submit, object htmlAttributes = null)
 {
     return WButtonHelper(null, href, title, icon, type, submit, htmlAttributes);
 }
示例#4
0
 public static MvcHtmlString WButton(this HtmlHelper html, string name, string title, WButtonType type, object htmlAttributes = null)
 {
     return WButton(html, name, title, null, type, false, htmlAttributes);
 }