Ejemplo n.º 1
0
        protected void Page_PreInit(object sender, EventArgs e)
        {
            string serverURLPath = LSKYCommon.getServerURLPath(Request);

            if (Request.Form.AllKeys.Contains("selectedMenuItem"))
            {
                int selectedID = 0;

                if (int.TryParse(Request.Form["selectedMenuItem"], out selectedID))
                {
                    if (selectedID != 0)
                    {
                        List <NavMenuItem> NavMenu = getMainMenu();
                        foreach (NavMenuItem mi in NavMenu)
                        {
                            if (mi.id == selectedID)
                            {
                                //Response.Redirect(serverURLPath + mi.url);
                                Redirect(LSKYCommon.translateLocalURL(mi.url));
                            }
                        }
                    }
                }
            }

            Redirect(LSKYCommon.translateLocalURL("/"));
        }
        private TableRow addNavItem(NavMenuItem item)
        {
            TableRow newRow = new TableRow();

            TableCell nameCell = new TableCell();

            string cssClass = "nav_link_normal";

            if (item.admin_only)
            {
                cssClass = "nav_link_admin";
            }

            nameCell.Text     = "<a href=\"" + LSKYCommon.translateLocalURL(item.url) + "\" class=\"" + cssClass + "\">" + item.name + "</a>";
            nameCell.CssClass = "navigation_table_name";
            newRow.Cells.Add(nameCell);

            TableCell descriptionCell = new TableCell();

            descriptionCell.Text     = item.description;
            descriptionCell.CssClass = "navigation_table_description";
            newRow.Cells.Add(descriptionCell);

            return(newRow);
        }
        public void displayNavDropdown()
        {
            /* Load the menu items */
            if (MainMenu == null)
            {
                MainMenu = Nav.getMainMenu();
            }

            // Figure out which menu items to display
            List <NavMenuItem> displayedMenuItems = new List <NavMenuItem>();

            foreach (NavMenuItem item in MainMenu)
            {
                if (!item.hidden)
                {
                    if (loggedInUser.is_admin)
                    {
                        displayedMenuItems.Add(item);
                    }
                    else
                    {
                        if ((!item.admin_only) && (!item.hidden))
                        {
                            displayedMenuItems.Add(item);
                        }
                    }
                }
            }
            displayedMenuItems.Sort();

            // Figure out which categories to display
            List <string> MenuCategories = new List <string>();

            foreach (NavMenuItem item in displayedMenuItems)
            {
                if (!MenuCategories.Contains(item.category))
                {
                    MenuCategories.Add(item.category);
                }
            }


            // Display the list in a dropdown box
            Response.Write("<form method=\"post\" action=\"" + LSKYCommon.translateLocalURL("Nav.aspx") + "\" style=\"margin: 0; padding: 0;\">");
            Response.Write("<span class=\"nav_link\">Navigation:</span> ");
            Response.Write("<select name=\"selectedMenuItem\">");
            Response.Write("<option value=\"0\" selected=\"selected\"> -- Front Page --</option>");
            foreach (string MenuCat in MenuCategories)
            {
                Response.Write("<option value=\"0\" style=\"font-weight: bold;\">" + MenuCat.ToUpper() + "</option>");
                foreach (NavMenuItem mi in displayedMenuItems)
                {
                    if (mi.category == MenuCat)
                    {
                        Response.Write("<option value=\"" + mi.id + "\">&nbsp;&nbsp;&nbsp;" + mi.name + "</option>");
                    }
                }
            }


            Response.Write("</select>");
            Response.Write("&nbsp;<input type=\"submit\" value=\"Go\">");
            Response.Write("</form>");
        }