Esempio n. 1
0
 private string MakeLevel2(int parentId)
 {
     T_MenuServices service = new T_MenuServices();
     IEnumerable<T_Menu> Level2 = service.GetChildren(parentId);
     StringBuilder sb = new StringBuilder();
     sb.Append("        <ul class='dropdown-menu'>");
     //Do level 1
     foreach (var item2 in Level2)
     {
         sb.AppendFormat("<li><a href='{0}'>{1}</a></li>", item2.Link, item2.Title);
     }
     sb.Append("</ul>");
     return sb.ToString();
 }
Esempio n. 2
0
        public string GetTopMenu()
        {
            T_MenuServices service = new T_MenuServices();
            StringBuilder sb = new StringBuilder();
            sb.Append("<ul class='nav navbar-nav pull-right mainNav'>");
            IEnumerable<T_Menu> Level1 = service.GetChildren(null);
            //Do level 1
            int ccount = 1;
            foreach (var item1 in Level1)
            {
                if (service.HasChild(item1.ID))
                {
                    sb.AppendFormat("<li class='c{0} dropdown'><a href='{1}' class='dropdown-toggle' data-toggle='dropdown'>{2} <b class='caret'></b></a>", ccount, item1.Link, item1.Title);
                    sb.Append(MakeLevel2(item1.ID));
                    sb.Append("</li>");
                }
                else
                {
                    sb.AppendFormat("<li class='c{0}'><a href='{1}'>{2}</a></li>", ccount, item1.Link, item1.Title);
                }
                ccount++;
            }

            sb.Append(" </ul>");
            sb.Append("      </div>");
            sb.Append("            </div>");
            return sb.ToString();
        }