private HtmlGenericControl CreateItemLinkToOpeMenu(string strOnClickMenu, FrwMenu item)
        {

            string onClickAction = "";
            if (!String.IsNullOrEmpty(item.objIdWindow.WindowPath) && !item.objIdWindow.WindowPath.Equals("#"))
            {
                onClickAction = String.Format(strOnClickMenu, item.objIdWindow.WindowTitle, item.objIdWindow.WindowPath);
            }

            HtmlGenericControl subMenuItemLi = new HtmlGenericControl("li");

            HtmlGenericControl subMenuItemLink = new HtmlGenericControl("a");
            subMenuItemLink.InnerText = item.WindowTitleMenu;
            if (!String.IsNullOrEmpty(onClickAction))
            {
                subMenuItemLink.Attributes.Add("onclick", onClickAction);
            }

            subMenuItemLi.Controls.Add(subMenuItemLink);

            return subMenuItemLi;
        }
        private HtmlGenericControl CreateMenuItemItem(FrwMenu item)
        {
            HtmlGenericControl idMenuItem = new HtmlGenericControl("li");
            idMenuItem.Attributes.Add("data-submenu-id", ("MenuItem" + item.IdMenu));

            HtmlGenericControl idMenuTitle = new HtmlGenericControl("a");
            idMenuTitle.InnerText = item.WindowTitleMenu;

            idMenuItem.Controls.Add(idMenuTitle);

            return idMenuItem;
        }
        private HtmlGenericControl CreateMenuItemItemSubMenu(FrwMenu subMenuItem)
        {
            bool hasChildren = false;

            KPSecuritySession securitySession = KPFormsAuthentication.SecuritySession;
            string strOnClickMenu = @"addNewTab('KPTabControl', '{0}', '{1}');";

            HtmlGenericControl subMenuItemControl = new HtmlGenericControl("div");
            subMenuItemControl.Attributes.Add("id", ("MenuItem" + subMenuItem.IdMenu));
            subMenuItemControl.Attributes.Add("class", "PopOverMenu");

            #region Title

            HtmlGenericControl subMenuItemTitle = new HtmlGenericControl("h3");
            subMenuItemTitle.Attributes.Add("class", "PopOverMenuTitle");
            subMenuItemTitle.InnerText = subMenuItem.WindowTitleMenu;

            #endregion
            subMenuItemControl.Controls.Add(subMenuItemTitle);

            HtmlGenericControl menuContent = new HtmlGenericControl("div");
            menuContent.Attributes.Add("class", "PopOverMenuContent");

            #region Menu Content Items

            HtmlGenericControl menuContentItems = new HtmlGenericControl("ul");
            menuContentItems.Attributes.Add("class", "PopOverMenuContentItems");

            PagePermission securityPage = null;
            bool itemNivel2Create = false;
            bool isOnlyMenuItem = false;
            FrwMenu parentNivel1Order = FrwMenu.TryFind(subMenuItem.IdMenu);
            FrwMenu[] frwMenuNivel1List = FrwMenu.FindAll(Order.Asc("Sequence"), Expression.And(Expression.Eq("IsVisible", StateVisibleEnum.Yes), Expression.Eq("objIdParent", parentNivel1Order)));
            foreach (FrwMenu itemNivel1 in frwMenuNivel1List)
            {

                isOnlyMenuItem = itemNivel1.objIdWindow.WindowEnum.Equals("_UNKNOW_");
                securityPage = securitySession.GetPagePermission(itemNivel1.objIdWindow.IdWindow);
                if (isOnlyMenuItem || (securityPage != null && securityPage.ExistPage && securityPage.IsPreview))
                {
                    HtmlGenericControl subMenuItemLi = this.CreateItemLinkToOpeMenu(strOnClickMenu, itemNivel1);

                    FrwMenu parentNivel2Order = FrwMenu.TryFind(itemNivel1.IdMenu);
                    FrwMenu[] frwMenuNivel2List = FrwMenu.FindAll(Order.Asc("Sequence"), Expression.And(Expression.Eq("IsVisible", StateVisibleEnum.Yes), Expression.Eq("objIdParent", parentNivel2Order)));
                    if (frwMenuNivel2List.Count() > 0)
                    {
                        HtmlGenericControl subSubMenuItem = new HtmlGenericControl("ul");
                        subSubMenuItem.Attributes.Add("class", "SubSubMenuItem");

                        itemNivel2Create = false;
                        foreach (FrwMenu itemNivel2 in frwMenuNivel2List)
                        {
                            if (itemNivel2 != null && itemNivel2.objIdWindow != null)
                            {
                                securityPage = securitySession.GetPagePermission(itemNivel2.objIdWindow.IdWindow);
                                if (securityPage != null && securityPage.ExistPage && securityPage.IsPreview)
                                {
                                    itemNivel2Create = true;
                                    HtmlGenericControl subSubMenuItemLi = this.CreateItemLinkToOpeMenu(strOnClickMenu, itemNivel2);
                                    subSubMenuItem.Controls.Add(subSubMenuItemLi);
                                }
                            }
                        }

                        if (itemNivel2Create || !isOnlyMenuItem)
                        {
                            hasChildren = true;
                            subMenuItemLi.Controls.Add(subSubMenuItem);
                        }
                    }

                    menuContentItems.Controls.Add(subMenuItemLi);
                }
            }

            #endregion Menu Content Items
            menuContent.Controls.Add(menuContentItems);

            #region Menu content image

            HtmlGenericControl menuContentImage = new HtmlGenericControl("img");
            menuContentImage.Attributes.Add("alt", subMenuItem.WindowTitleMenu);
            menuContentImage.Attributes.Add("src", subMenuItem.ImageUrl);

            #endregion Menu content image
            menuContent.Controls.Add(menuContentImage);

            subMenuItemControl.Controls.Add(menuContent);

            if (!hasChildren)
            {
                subMenuItemControl = null;
            }


            return subMenuItemControl;
        }
        /// <summary>
        /// Create the items to the menu Item
        /// </summary>
        /// <param name="frwMenuItemList"></param>
        /// <returns>An HtmlGenericControl with items to be add to MenuItem</returns>
        private HtmlGenericControl CreateMenuItemItems(FrwMenu[] frwMenuItemList)
        {
            HtmlGenericControl menuItem = new HtmlGenericControl("ul");
            menuItem.Attributes.Add("class", "DropdownMenu DropdownMenuHidden");
            /*
            foreach (FrwMenu item in frwMenuItemList)
            {
                HtmlGenericControl idMenuItem = new HtmlGenericControl("li");
                idMenuItem.Attributes.Add("data-submenu-id", ("MenuItem" + item.IdMenu));

                HtmlGenericControl idMenuTitle = new HtmlGenericControl("a");
                idMenuTitle.InnerText = item.WindowTitleMenu;

                idMenuItem.Controls.Add(idMenuTitle);

                menuItem.Controls.Add(idMenuItem);
            }
            */
            return menuItem;
        }