protected virtual string RenderLink() { CleanTagBuilder anchor = new CleanTagBuilder("a"); if (ItemDisabled) anchor.AddCssClass(DisabledClass); else anchor.Attributes["href"] = ActionUrl; if(IsItemSelected()) anchor.AddCssClass(SelectedClass); anchor.Attributes["title"] = HelpText; anchor.InnerHtml += RenderIcon() + RenderTitle(); return anchor.ToString(TagRenderMode.Normal); }
protected virtual string RenderIcon() { if (!string.IsNullOrEmpty(Icon)) { string iconPath = (IconDirectory ?? "") + Icon; CleanTagBuilder icon = new CleanTagBuilder("img"); icon.Attributes["border"] = "0"; icon.Attributes["src"] = iconPath; icon.Attributes["alt"] = Title; icon.AddCssClass(IconClass); return icon.ToString(TagRenderMode.SelfClosing); } return string.Empty; }
protected virtual string RenderIcon() { if (!string.IsNullOrEmpty(Icon)) { string iconPath = (IconDirectory ?? "") + Icon; CleanTagBuilder icon = new CleanTagBuilder("img"); icon.Attributes["border"] = "0"; icon.Attributes["src"] = iconPath; icon.Attributes["alt"] = Title; icon.AddCssClass(IconClass); return(icon.ToString(TagRenderMode.SelfClosing)); } return(string.Empty); }
protected virtual string RenderItems() { if (items.Count <= 0) { return(string.Empty); } CleanTagBuilder ul = new CleanTagBuilder("ul"); ul.AddCssClass(ListClass); foreach (var menuBase in items) { ul.InnerHtml += menuBase.RenderHtml(); } return(ul.ToString(TagRenderMode.Normal)); }
/// <summary> /// Used internally to render the menu. Do not call this directly without first calling Prepare, or call RenderHtml(RequestContext ...) /// </summary> public virtual string RenderHtml() { if (!Prepared) { throw new InvalidOperationException("Must call Prepare before RenderHtml() or call RenderHtml(RequestContext, TextWriter)"); } if (HideItem) { return(string.Empty); } CleanTagBuilder li = new CleanTagBuilder("li"); li.AddCssClass(ItemClass); li.InnerHtml = RenderLink(); return(li.ToString(TagRenderMode.Normal)); }
protected virtual string RenderLink() { CleanTagBuilder anchor = new CleanTagBuilder("a"); if (ItemDisabled) { anchor.AddCssClass(DisabledClass); } else { anchor.Attributes["href"] = ActionUrl; } if (IsItemSelected()) { anchor.AddCssClass(SelectedClass); } anchor.Attributes["title"] = HelpText; anchor.InnerHtml += RenderIcon() + RenderTitle(); return(anchor.ToString(TagRenderMode.Normal)); }
public override string RenderHtml() { if (!Prepared) { throw new InvalidOperationException("Must call Prepare before RenderHtml(TextWriter) or call RenderHtml(RequestContext, TextWriter)"); } if (HideItem) { return(string.Empty); } if (!IsRootList && HasSingleRenderableItem()) { return(items[0].RenderHtml()); //if there is only one item, don't render this menu instead skip to the item } if (IsRootList) { return(RenderItems()); } CleanTagBuilder li = new CleanTagBuilder("li"); li.AddCssClass(ItemClass); li.InnerHtml = RenderLink() + RenderItems(); return(li.ToString(TagRenderMode.Normal)); }
/// <summary> /// Used internally to render the menu. Do not call this directly without first calling Prepare, or call RenderHtml(RequestContext ...) /// </summary> public virtual string RenderHtml() { if (!Prepared) throw new InvalidOperationException("Must call Prepare before RenderHtml() or call RenderHtml(RequestContext, TextWriter)"); if (HideItem) return string.Empty; CleanTagBuilder li = new CleanTagBuilder("li"); li.AddCssClass(ItemClass); li.InnerHtml = RenderLink(); return li.ToString(TagRenderMode.Normal); }