Exemple #1
0
 //Get all the child of a parent menu item
 private static List<Menu> GetChildItems(Menu parentMenu, List<Menu> menuList)
 {
     return menuList.Where(x => x.ParentId == parentMenu.MenuId).OrderBy(x => x.MenuOrder).ToList();
 }
Exemple #2
0
 private static void AddChild(HtmlTextWriter writer, Menu parentMenu, List<Menu> menuList, Languages language)
 {
     List<Menu> childItems = menuList.Where(x => x.IsAdded == false && x.ParentId == parentMenu.MenuId).ToList();
     if (childItems.Count == 0)
         return;
     writer.RenderBeginTag(HtmlTextWriterTag.Ul); // 1
     for (int i = 0; i < childItems.Count; i++)
     {
         if (!childItems[i].IsAdded)
         {
             writer.RenderBeginTag(HtmlTextWriterTag.Li); // 2
             AddOnClickOnNoLink(writer, childItems[i]);
             writer.RenderBeginTag(HtmlTextWriterTag.A); //3
             writer.Write(language == Languages.Hindi ? childItems[i].TextHindi : childItems[i].TextEnglish);
             writer.RenderEndTag(); // End of tag 3
             childItems[i].IsAdded = true;
             AddChild(writer, childItems[i], menuList, language);
             writer.RenderEndTag(); // End of tag 2
         }
     }
     writer.RenderEndTag(); // End of tag 1
 }
Exemple #3
0
 private static void AddOnClickOnNoLink(HtmlTextWriter writer, Menu menu)
 {
     switch (menu.MenuLink)
     {
         case "#":
             writer.AddAttribute(HtmlTextWriterAttribute.Onclick, "javascript:return false;");
             writer.AddAttribute(HtmlTextWriterAttribute.Href, menu.MenuLink);
             break;
         default:
             if (menu.LinkSiteId!=-1)
             {
                 writer.AddAttribute(HtmlTextWriterAttribute.Href, menu.MenuLink + "?d=" + BllEncryption.UrlEncode(menu.LinkSiteId.ToString(CultureInfo.InvariantCulture)));
             }
             else
             {
                 writer.AddAttribute(HtmlTextWriterAttribute.Href, menu.MenuLink);
             }
             break;
     }
 }
Exemple #4
0
        public static List<Menu> GetMenu(DataTable dt)
        {
            if (dt.Rows.Count == 0)
                return null;
            List<Menu> menuList = new List<Menu>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                Menu m = new Menu();
                m.MenuId = (int)dt.Rows[i]["ID"];
                m.TextEnglish = (string)dt.Rows[i]["TextEnglish"];
                m.TextHindi = (string)dt.Rows[i]["TextHindi"];
                m.ParentId = (int)dt.Rows[i]["ParentId"];
                m.Status = true;
                m.UpdatedBy = (string)dt.Rows[i]["UpdatedBy"];
                m.UpdatedOn = (DateTime)dt.Rows[i]["UpdatedOn"];
                m.MenuOrder = (int)dt.Rows[i]["MenuOrder"];
                m.MenuLink = (string)dt.Rows[i]["Link"];
                //m.PageType= (int)dt.Rows[i]["PageType"];
                m.MenuLevel = (int)dt.Rows[i]["MenuLevel"];
                m.IsAdded = false;
                m.RegionId = (int)dt.Rows[i]["SiteId"];
                m.IsVisibleToOther = (bool)dt.Rows[i]["IsVisibleToOther"];
                m.LinkSiteId = (int)dt.Rows[i]["LinkSiteId"];
                menuList.Add(m);
            }
            return menuList;
        }