コード例 #1
0
        public virtual MvcHtmlString ToHtml()
        {
            var a = GetLinkElement();

            var result = new HtmlTag("li").InnerHtml(a.ToHtml());

            if (Tooltip.HasText())
            {
                result.Attr("data-toggle", "tooltip");
                result.Attr("data-placement", "left");
                result.Attr("title", Tooltip);
            }

            var html = result.ToHtml();

            if (OnClick == null)
            {
                return(html);
            }

            TypeContext.AssertId(this.Id);

            var script = MvcHtmlString.Create("<script>$('#" + Id + "').on('mouseup', function(event){ if(event.which == 3) return; " + OnClick.ToString() + " })</script>");

            return(html.Concat(script));
        }
コード例 #2
0
        public virtual MvcHtmlString ToHtml(HtmlHelper helper)
        {
            var a = new HtmlTag("a")
                    .Id(Id)
                    .Class("btn")
                    .Class("btn-" + Style.ToString().ToLower())
                    .Class("sf-entity-button")
                    .Class(CssClass)
                    .Attrs(HtmlProps);

            if (Text != null)
            {
                a.SetInnerText(Text);
            }

            if (Html != null)
            {
                a.InnerHtml(Html);
            }

            if (Title.HasText())
            {
                a.Attr("title", Title);
            }

            if (Href != null)
            {
                a.Attr("href", Href);
            }

            if (!Enabled)
            {
                a.Attr("disabled", "disabled");
            }

            var result = new HtmlTag("div").Class("btn-group").InnerHtml(a);

            if (Tooltip.HasText())
            {
                result.Attr("data-toggle", "tooltip");
                result.Attr("data-placement", "bottom");
                result.Attr("title", Tooltip);
            }

            var html = result.ToHtml();

            if (OnClick == null)
            {
                return(html);
            }

            TypeContext.AssertId(this.Id);

            var script = MvcHtmlString.Create("<script>$('#" + Id + "').on('mouseup', function(event){ if(event.which == 3) return; " + OnClick.ToString() + " })</script>");

            return(html.Concat(script));
        }