protected override void RenderPart(LinqIt.Utils.Web.HtmlWriter writer) { var topMenuItems = DataService.Instance.GetTopMenuItems(); writer.RenderBeginTag(HtmlTextWriterTag.Ul, "nav"); foreach (var topItem in topMenuItems) { if (topItem.HasChildren) writer.AddClass("dropdown"); writer.RenderBeginTag(HtmlTextWriterTag.Li); writer.AddAttribute(HtmlTextWriterAttribute.Href, topItem.Url); writer.RenderFullTag(HtmlTextWriterTag.A, topItem.DisplayName); if (topItem.HasChildren) { writer.AddAttribute("data-toggle", "dropdown"); writer.AddAttribute(HtmlTextWriterAttribute.Href, "#"); writer.RenderBeginTag(HtmlTextWriterTag.A, "dropdown-toggle"); writer.RenderFullTag(HtmlTextWriterTag.B, "", "caret"); writer.RenderEndTag(); // a.dropdown-toggle writer.RenderBeginTag(HtmlTextWriterTag.Ul, "dropdown-menu"); foreach (var child in topItem.Children) { writer.RenderBeginTag(HtmlTextWriterTag.Li); writer.AddAttribute(HtmlTextWriterAttribute.Href, child.Url); writer.RenderFullTag(HtmlTextWriterTag.A, child.DisplayName); writer.RenderEndTag(); // li } writer.RenderEndTag(); // ul.dropdown-menu } writer.RenderEndTag(); // li } writer.RenderEndTag(); // ul.nav }
private static void RenderMenuItem(LinqIt.Utils.Web.HtmlWriter writer, Entities.MenuItem menuItem) { if (menuItem.Selected) writer.AddClass("selected"); if (menuItem.Expanded) writer.AddClass("expanded"); if (menuItem.Collapsed) writer.AddClass("collapsed"); writer.RenderBeginTag(HtmlTextWriterTag.Li); writer.AddAttribute(HtmlTextWriterAttribute.Href, menuItem.Url); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.RenderFullTag(HtmlTextWriterTag.Span, menuItem.DisplayName); writer.RenderEndTag(); // a if (menuItem.HasChildren) { writer.RenderBeginTag(HtmlTextWriterTag.Ul); foreach (var child in menuItem.Children) RenderMenuItem(writer, child); writer.RenderEndTag(); // ul } writer.RenderEndTag(); // li }
protected override void RenderPart(LinqIt.Utils.Web.HtmlWriter writer) { if (!Visible) return; writer.RenderBeginTag(HtmlTextWriterTag.Div, "navbar"); writer.RenderBeginTag(HtmlTextWriterTag.Div, "navbar-inner"); writer.RenderBeginTag(HtmlTextWriterTag.Ul, "nav"); foreach (var menuItem in _menuItems) { if (menuItem.Selected || menuItem.Expanded) writer.AddClass("active"); writer.RenderBeginTag(HtmlTextWriterTag.Li); writer.AddAttribute(HtmlTextWriterAttribute.Href, menuItem.Url); writer.RenderFullTag(HtmlTextWriterTag.A, menuItem.DisplayName); writer.RenderEndTag(); // li.active } writer.RenderEndTag(); // ul.nav writer.RenderEndTag(); // div.navbar-inner writer.RenderEndTag(); // div.navbar }