public SetInnerText ( string innerText ) : |
||
innerText | string | |
Результат |
protected virtual HtmlTag GetLinkElement() { var a = new HtmlTag("a") .Id(Id) .Class("bg-" + Style.ToString().ToLower()) .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"); } return(a); }
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)); }
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); }
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 (Enabled) { if (OnClick != null) a.Attr("onclick", OnClick.ToString()); a.Attr("href", Href.DefaultText("#")); } else 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); } return result; }
} //is applied to link public void Write(HtmlStringBuilder sb, string currentUrl, int depth) { if (!this.Visible) { throw new InvalidOperationException("Invisible menu"); } bool isActive = this.Link != null && this.Link.ToString() == currentUrl || children.HasItems() && children.Any(a => a.Link != null && a.Link.ToString() == currentUrl); bool isHeader = IsHeader(depth); using (sb.SurroundLine(new HtmlTag("li").Class(isActive ? "active" : null).Class(isHeader ? "dropdown-header" : this.children.HasItems() ? "dropdown" : null))) { if (Link != null) { string link = Link.ToString(); if (ManualA != null) { sb.AddLine(ManualA(link, title, " ".CombineIfNotEmpty(Class, "selected"))); } else { HtmlTag tbA = new HtmlTag("a") .Attrs(new { href = link, title = Title, id = Id }) .Class(Class); if (Html != null) { tbA.InnerHtml(Html); } else { tbA.SetInnerText(Text); } sb.AddLine(tbA.ToHtml()); } } else if (this.children.HasItems() && !isHeader) { using (sb.SurroundLine(new HtmlTag("a").Attr("href", "#") .Class("dropdown-toggle") .Class(Class) .Attr("data-toggle", "dropdown"))) { if (Html != null) { sb.Add(Html); } else { sb.Add(new HtmlTag("span").SetInnerText(Text)); } sb.Add(new HtmlTag("b").Class("caret")); } } else if (Html != null) { sb.AddLine(Html); } else { sb.AddLine(new HtmlTag("span").SetInnerText(Text)); } if (this.children.HasItems() && !isHeader) { using (sb.SurroundLine(new HtmlTag("ul").Class("dropdown-menu"))) { bool lastHeader = false; foreach (WebMenuItem menu in this.children) { if (menu.Visible) { if (lastHeader) { sb.AddLine(new HtmlTag("li").Class("divider")); } menu.Write(sb, currentUrl, depth + 1); lastHeader = menu.IsHeader(depth + 1); } } } } } if (isHeader) { foreach (WebMenuItem menu in this.children) { if (menu.Visible) { menu.Write(sb, currentUrl, depth + 1); } } } }
protected virtual HtmlTag GetLinkElement() { var a = new HtmlTag("a") .Id(Id) .Class("bg-" + Style.ToString().ToLower()) .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"); return a; }
public string Class { get; set; } //is applied to link public void Write(HtmlStringBuilder sb, string currentUrl, int depth) { if (!this.Visible) throw new InvalidOperationException("Invisible menu"); bool isActive = this.Link != null && this.Link.ToString() == currentUrl || children.HasItems() && children.Any(a => a.Link != null && a.Link.ToString() == currentUrl); bool isHeader = IsHeader(depth); using (sb.SurroundLine(new HtmlTag("li").Class(isActive ? "active" : null).Class(isHeader ? "dropdown-header" : this.children.HasItems() ? "dropdown" : null))) { if (Link != null) { string link = Link.ToString(); if (ManualA != null) sb.AddLine(ManualA(link, title, " ".CombineIfNotEmpty(Class, "selected"))); else { HtmlTag tbA = new HtmlTag("a") .Attrs(new { href = link, title = Title, id = Id }) .Class(Class); if (Html != null) tbA.InnerHtml(Html); else tbA.SetInnerText(Text); sb.AddLine(tbA.ToHtml()); } } else if (this.children.HasItems() && !isHeader) { using (sb.SurroundLine(new HtmlTag("a").Attr("href", "#") .Class("dropdown-toggle") .Class(Class) .Attr("data-toggle", "dropdown"))) { if (Html != null) sb.Add(Html); else sb.Add(new HtmlTag("span").SetInnerText(Text)); sb.Add(new HtmlTag("b").Class("caret")); } } else if (Html != null) sb.AddLine(Html); else sb.AddLine(new HtmlTag("span").SetInnerText(Text)); if (this.children.HasItems() && !isHeader) { using (sb.SurroundLine(new HtmlTag("ul").Class("dropdown-menu"))) { bool lastHeader = false; foreach (WebMenuItem menu in this.children) { if (menu.Visible) { if(lastHeader) sb.AddLine(new HtmlTag("li").Class("divider")); menu.Write(sb, currentUrl, depth + 1); lastHeader = menu.IsHeader(depth + 1); } } } } } if (isHeader) { foreach (WebMenuItem menu in this.children) { if (menu.Visible) menu.Write(sb, currentUrl, depth + 1); } } }