Esempio n. 1
0
    private void Page_Load(object sender, System.EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            EasyMenu1             = new EasyMenu();
            EasyMenu1.ID          = "EasyMenu1";
            EasyMenu1.StyleFolder = "styles/windowsxp";
            EasyMenu1.IconsFolder = "icons";
            EasyMenu1.UseIcons    = true;
            EasyMenu1.Width       = "140";
            EasyMenu1.AttachTo    = "div1";
            EasyMenu1.ShowEvent   = MenuShowEvent.ContextMenu;
            EasyMenu1.Align       = MenuAlign.Under;

            // add the items for the menu
            EasyMenu1.AddMenuItem("menuItem1", "<span style='color:#666666; font:bold; cursor:pointer;'>obout.com<b style='color:crimson; text-decoration:none;'> Home</b></span>", null, "http://www.obout.com", "_blank", null);
            EasyMenu1.AddMenuItem("menuItem2", "Alert", null, null, null, "alert('you just clicked Alert')");
            EasyMenu1.AddMenuItem("menuItem3", "<input type='checkbox' style='height:14px; width:14px;' checked='1'> Any <span style='background-color:gold; padding-left:2px; padding-right:2px;'>HTML</span>", null, null, null, null);
            EasyMenu1.AddSeparator("menuSeparator1", "");
            EasyMenu1.AddMenuItem("menuItem4", "Browser Operation", null, null, null, null);
            EasyMenu1.AddSeparator("menuSeparator2", "");
            EasyMenu1.AddMenuItem("menuItem5", "Recycle", "xpRecycle.gif", null, null, null);

            // add the menu to the placeholder on the page
            placeHolder1.Controls.Add(EasyMenu1);

            EasyMenu2             = new EasyMenu();
            EasyMenu2.ID          = "EasyMenu2";
            EasyMenu2.StyleFolder = "styles/windowsxp";
            EasyMenu2.IconsFolder = "icons";
            EasyMenu2.UseIcons    = true;
            EasyMenu2.Width       = "140";
            EasyMenu2.AttachTo    = "menuItem4";
            EasyMenu2.ShowEvent   = MenuShowEvent.MouseOver;
            EasyMenu2.Align       = MenuAlign.Right;

            // add the items for the menu
            EasyMenu2.AddMenuItem("menuItem11", "Open New Page", "new.gif", "about:blank", "_blank", null);
            EasyMenu2.AddMenuItem("menuItem12", "Close This Page", "delete.gif", null, null, "try {window.opener.focus(); window.opener = this; window.close();} catch (e) {};");

            placeHolder1.Controls.Add(EasyMenu2);
        }
    }
Esempio n. 2
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                // create the Parent EasyMenu
                mainEM = new EasyMenu();
                // set the ID (must be unique)
                mainEM.ID = "MainEM";
                // set the style for this menu
                mainEM.StyleFolder = "styles/horizontal7";
                mainEM.Width       = "330";
                // show event is always so the menu is always visible
                // this menu doesn't require any AttachTo or Align properties set
                mainEM.ShowEvent = MenuShowEvent.Always;
                // display the menu horizontally
                mainEM.Position = MenuPosition.Horizontal;

                // the parent menu looks different so we need to set different
                // CSS classes names for its items and the menu itself

                // css classes names for the menu and the item container
                mainEM.CSSMenu = "ParentMenu";
                mainEM.CSSMenuItemContainer = "ParentItemContainer";

                // css classes names for MenuItems
                CSSClasses MenuItemCssClasses = mainEM.CSSClassesCollection[mainEM.CSSClassesCollection.Add(new CSSClasses(typeof(MenuItem)))];
                MenuItemCssClasses.ComponentSubMenuCellOver = "ParentItemSubMenuCellOver";
                MenuItemCssClasses.ComponentContentCell     = "ParentItemContentCell";
                MenuItemCssClasses.Component                = "ParentItem";
                MenuItemCssClasses.ComponentSubMenuCell     = "ParentItemSubMenuCell";
                MenuItemCssClasses.ComponentIconCellOver    = "ParentItemIconCellOver";
                MenuItemCssClasses.ComponentIconCell        = "ParentItemIconCell";
                MenuItemCssClasses.ComponentOver            = "ParentItemOver";
                MenuItemCssClasses.ComponentContentCellOver = "ParentItemContentCellOver";
                // add the classes names to the collection
                mainEM.CSSClassesCollection.Add(MenuItemCssClasses);

                // css classes names for MenuSeparators
                CSSClasses MenuSeparatorCssClasses = mainEM.CSSClassesCollection[mainEM.CSSClassesCollection.Add(new CSSClasses(typeof(MenuSeparator)))];
                MenuSeparatorCssClasses.ComponentSubMenuCellOver = "ParentSeparatorSubMenuCellOver";
                MenuSeparatorCssClasses.ComponentContentCell     = "ParentSeparatorContentCell";
                MenuSeparatorCssClasses.Component                = "ParentSeparator";
                MenuSeparatorCssClasses.ComponentSubMenuCell     = "ParentSeparatorSubMenuCell";
                MenuSeparatorCssClasses.ComponentIconCellOver    = "ParentSeparatorIconCellOver";
                MenuSeparatorCssClasses.ComponentIconCell        = "ParentSeparatorIconCell";
                MenuSeparatorCssClasses.ComponentOver            = "ParentSeparatorOver";
                MenuSeparatorCssClasses.ComponentContentCellOver = "ParentSeparatorContentCellOver";
                // add the classes names to the collection
                mainEM.CSSClassesCollection.Add(MenuSeparatorCssClasses);

                // add the items for the menu
                mainEM.AddItem(new MenuItem("item1", "Item 1", "", "", "", ""));
                mainEM.AddSeparator("mainMenuSeparator1", "&nbsp;");
                mainEM.AddItem(new MenuItem("item2", "Item 2", "", "", "", ""));
                mainEM.AddSeparator("mainMenuSeparator2", "&nbsp;");
                mainEM.AddItem(new MenuItem("item3", "Item 3", "", "", "", ""));
                mainEM.AddSeparator("mainMenuSeparator3", "&nbsp;");
                mainEM.AddItem(new MenuItem("item4", "Item 4", "", "", "", ""));
                mainEM.AddSeparator("mainMenuSeparator4", "&nbsp;");
                mainEM.AddItem(new MenuItem("item5", "Item 5", "", "", "", ""));

                // add the menu to the placeholder on the page
                placeHolder1.Controls.Add(mainEM);


                // Create the submenus
                em_1    = new EasyMenu();
                em_1.ID = "Easymenu1";
                // this will attach to the first item of the parent menu (id=item1)
                em_1.AttachTo    = "item1";
                em_1.StyleFolder = "styles/horizontal7";
                em_1.Width       = "140";
                // it will show on mouse over
                em_1.ShowEvent = MenuShowEvent.MouseOver;
                // and will align under the item to which it is attached
                em_1.Align          = MenuAlign.Under;
                em_1.OffsetVertical = -2;
                // here are this menu's items
                em_1.AddItem(new MenuItem("menuItem1", "SubItem 1", "", "", "", "alert('Item 1 - SubItem 1')"));
                em_1.AddItem(new MenuItem("menuItem2", "SubItem 2", "", "", "", "alert('Item 1 - SubItem 2')"));
                em_1.AddItem(new MenuItem("menuItem3", "SubItem 3", "", "", "", "alert('Item 1 - SubItem 3')"));
                em_1.AddItem(new MenuItem("menuItem4", "SubItem 4", "", "", "", "alert('Item 1 - SubItem 4')"));
                em_1.AddItem(new MenuItem("menuItem5", "SubItem 5", "", "", "", "alert('Item 1 - SubItem 5')"));

                // and so on for every submenu
                em_2                = new EasyMenu();
                em_2.ID             = "Easymenu2";
                em_2.AttachTo       = "item2";
                em_2.StyleFolder    = "styles/horizontal7";
                em_2.Width          = "140";
                em_2.ShowEvent      = MenuShowEvent.MouseOver;
                em_2.Align          = MenuAlign.Under;
                em_2.OffsetVertical = -2;
                em_2.AddItem(new MenuItem("menuItem6", "SubItem 1", "", "", "", "alert('Item 2 - SubItem 1')"));
                em_2.AddItem(new MenuItem("menuItem7", "SubItem 2", "", "", "", "alert('Item 2 - SubItem 2')"));
                em_2.AddItem(new MenuItem("menuItem8", "SubItem 3", "", "", "", "alert('Item 2 - SubItem 3')"));

                em_4                = new EasyMenu();
                em_4.ID             = "Easymenu4";
                em_4.AttachTo       = "item4";
                em_4.StyleFolder    = "styles/horizontal7";
                em_4.Width          = "140";
                em_4.OffsetVertical = -2;
                em_4.ShowEvent      = MenuShowEvent.MouseOver;
                em_4.Align          = MenuAlign.Under;
                em_4.AddItem(new MenuItem("menuItem9", "SubItem 1", "", "", "", "alert('Item 4 - SubItem 1')"));
                em_4.AddItem(new MenuItem("menuItem10", "SubItem 2", "", "", "", "alert('Item 4 - SubItem 2')"));

                em_5                = new EasyMenu();
                em_5.ID             = "Easymenu5";
                em_5.AttachTo       = "item5";
                em_5.StyleFolder    = "styles/horizontal7";
                em_5.Width          = "140";
                em_5.OffsetVertical = -2;
                em_5.ShowEvent      = MenuShowEvent.MouseOver;
                em_5.Align          = MenuAlign.Under;
                em_5.AddItem(new MenuItem("menuItem11", "SubItem 1", "", "", "", "alert('Item 5 - SubItem 1')"));
                em_5.AddItem(new MenuItem("menuItem12", "SubItem 2", "", "", "", "alert('Item 5 - SubItem 2')"));
                em_5.AddItem(new MenuItem("menuItem13", "SubItem 3", "", "", "", "alert('Item 5 - SubItem 3')"));
                em_5.AddItem(new MenuItem("menuItem14", "SubItem 4", "", "", "", "alert('Item 5 - SubItem 4')"));
                em_5.AddItem(new MenuItem("menuItem15", "SubItem 5", "", "", "", "alert('Item 5 - SubItem 5')"));

                em_6                  = new EasyMenu();
                em_6.ID               = "Easymenu6";
                em_6.AttachTo         = "menuItem3";
                em_6.StyleFolder      = "styles/horizontal7";
                em_6.Width            = "140";
                em_6.ShowEvent        = MenuShowEvent.MouseOver;
                em_6.Align            = MenuAlign.Right;
                em_6.OffsetVertical   = 0;
                em_6.OffsetHorizontal = -4;
                em_6.AddItem(new MenuItem("menuItem31", "SubItem 1", "", "", "", "alert('Item 1 - SubItem 3 - SubItem 1')"));
                em_6.AddItem(new MenuItem("menuItem32", "SubItem 2", "", "", "", "alert('Item 1 - SubItem 3 - SubItem 2')"));
                em_6.AddItem(new MenuItem("menuItem33", "SubItem 3", "", "", "", "alert('Item 1 - SubItem 3 - SubItem 3')"));

                // add the submenus to the page
                placeHolder1.Controls.Add(em_1);
                placeHolder1.Controls.Add(em_2);
                placeHolder1.Controls.Add(em_4);
                placeHolder1.Controls.Add(em_5);
                placeHolder1.Controls.Add(em_6);
            }
        }
Esempio n. 3
0
    //
    // TODO: Add constructor logic here
    //
    public void PopulateStoreMenu2(EasyMenu ctrlMenu, EasyMenu[] ids)
    {
        //check if the product already exists in the cache
        System.Data.DataSet ds = (System.Data.DataSet)HttpContext.Current.Cache["MenuNavigation"];

        if (ds == null)
        {
            CategoryHelper categoryHelper = new CategoryHelper();
            ds = categoryHelper.GetNavigationItems(ZNodeConfigManager.SiteConfig.PortalID);

            //add the hierarchical relationship to the dataset
            ds.Relations.Add("NodeRelation", ds.Tables[0].Columns["CategoryId"], ds.Tables[0].Columns["ParentCategoryId"]);

            HttpContext.Current.Cache["MenuNavigation"] = ds;
        }
        System.Data.DataSet dsBrands = (System.Data.DataSet)HttpContext.Current.Cache["SubMenuBrands"];

        if (dsBrands == null)
        {
            GoOpticCategoryHelper gocategoryHelper = new GoOpticCategoryHelper();
            dsBrands = gocategoryHelper.GetBrands(ZNodeConfigManager.SiteConfig.PortalID);

            //add the hierarchical relationship to the dataset
            //dsBrands.Relations.Add("NodeRelation", ds.Tables[0].Columns["CategoryId"], ds.Tables[0].Columns["ParentCategoryId"]);

            HttpContext.Current.Cache["SubMenuBrands"] = dsBrands;
        }

        int CategoryNo = 0;
        foreach (DataRow dbRow in ds.Tables[0].Rows)
        {
            if (dbRow.IsNull("ParentCategoryID"))
            {
                if ((bool)dbRow["VisibleInd"])
                {
                    //create new menu item
                    // string itemText = dbRow["Name"].ToString();
                    int rows;
                    try
                    {
                        rows = Int32.Parse(dbRow["Rows"].ToString());
                    }
                    catch (Exception e)
                    { rows = 0; }
                    int columns;
                    try
                    {
                        columns = Int32.Parse(dbRow["Columns"].ToString());
                    }
                    catch (Exception e)
                    { columns = 0; }

                    string categoryId = dbRow["CategoryId"].ToString();
                    string seoURL = dbRow["SEOURL"].ToString();
                    string imageName=dbRow["ImageFile"].ToString();
                    string imageNameHOver = imageName.Replace(".","HOver.");
                    string imagePath = ZNode.Libraries.Framework.Business.ZNodeConfigManager.EnvironmentConfig.OriginalImagePath +imageName ;
                    imagePath = imagePath.Replace("~","");
                    string imagePathHOver = ZNode.Libraries.Framework.Business.ZNodeConfigManager.EnvironmentConfig.OriginalImagePath+imageNameHOver;
                    imagePathHOver = imagePathHOver.Replace("~", "");

                    string categoryText = dbRow["Name"].ToString();
                    if (categoryText.ToLower() == "home")
                        seoURL = "~/";
                    else
                        seoURL = ZNodeSEOUrl.MakeURL(categoryId, SEOUrlType.Category, seoURL);
                    imageName = imageName.Remove(imageName.IndexOf("."), imageName.Length - imageName.IndexOf("."));
                    string itemText = "<a href=\"" + seoURL.Replace("~","") + "\" onmouseover=\"roll_over('" + imageName + "', '" + imagePathHOver + "')\"  onmouseout=\"roll_over('" + imageName + "', '" + imagePath + "')\" ><img border=\"0\"  name =\"" + imageName + "\" src=\"" + imagePath + "\"/>";
                    //  itemText = itemText.Replace("default", imagePath);

                    categoryText = categoryText.Replace(" ", "");
                    string sepID = "sep" + categoryText;
                    string sepPath = "<img  src=\"~/Images/home/bete.png\"/>";
                    sepPath = sepPath.Replace("~", "");

                    if(CategoryNo!=0)
                        ctrlMenu.AddSeparator(sepID, sepPath);
                    OboutInc.EasyMenu_Pro.MenuItem mi = new OboutInc.EasyMenu_Pro.MenuItem(categoryText, itemText, "","", "", "");
                    ctrlMenu.AddItem(mi);

                    ids[CategoryNo].AttachTo = categoryText;
                    //recursively populate node
                    if (categoryText.ToLower() == "brands")
                    {
                        RecursivelyPopulateMenuBrands(ids[CategoryNo], rows, columns);
                    }
                    else
                    {
                        RecursivelyPopulateMenuSubCategory(dbRow, ids[CategoryNo], dsBrands, rows, columns);
                        // RecursivelyPopulateMenuBrands(ids[CategoryNo], categoryId, dsBrands);
                   }
                    CategoryNo++;
                }
            }
        }
    }
		private void Page_Load(object sender, System.EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				// create the Parent EasyMenu
				mainEM = new EasyMenu();
				// set the ID (must be unique)
				mainEM.ID = "MainEM";
				// set the style for this menu
				mainEM.StyleFolder = "styles/horizontal7";
				mainEM.Width = "330";
				// show event is always so the menu is always visible
				// this menu doesn't require any AttachTo or Align properties set
				mainEM.ShowEvent = MenuShowEvent.Always;
				// display the menu horizontally
				mainEM.Position = MenuPosition.Horizontal;

				// the parent menu looks different so we need to set different
				// CSS classes names for its items and the menu itself
				
				// css classes names for the menu and the item container
				mainEM.CSSMenu = "ParentMenu";
				mainEM.CSSMenuItemContainer = "ParentItemContainer";
				
				// css classes names for MenuItems
				CSSClasses MenuItemCssClasses = mainEM.CSSClassesCollection[mainEM.CSSClassesCollection.Add(new CSSClasses(typeof(MenuItem)))];
				MenuItemCssClasses.ComponentSubMenuCellOver="ParentItemSubMenuCellOver";
				MenuItemCssClasses.ComponentContentCell="ParentItemContentCell";
				MenuItemCssClasses.Component="ParentItem";
				MenuItemCssClasses.ComponentSubMenuCell="ParentItemSubMenuCell";
				MenuItemCssClasses.ComponentIconCellOver="ParentItemIconCellOver";
				MenuItemCssClasses.ComponentIconCell="ParentItemIconCell";
				MenuItemCssClasses.ComponentOver="ParentItemOver";
				MenuItemCssClasses.ComponentContentCellOver="ParentItemContentCellOver";
				// add the classes names to the collection
				mainEM.CSSClassesCollection.Add(MenuItemCssClasses);
				
				// css classes names for MenuSeparators
				CSSClasses MenuSeparatorCssClasses = mainEM.CSSClassesCollection[mainEM.CSSClassesCollection.Add(new CSSClasses(typeof(MenuSeparator)))];
				MenuSeparatorCssClasses.ComponentSubMenuCellOver="ParentSeparatorSubMenuCellOver";
				MenuSeparatorCssClasses.ComponentContentCell="ParentSeparatorContentCell";
				MenuSeparatorCssClasses.Component="ParentSeparator";
				MenuSeparatorCssClasses.ComponentSubMenuCell="ParentSeparatorSubMenuCell";
				MenuSeparatorCssClasses.ComponentIconCellOver="ParentSeparatorIconCellOver";
				MenuSeparatorCssClasses.ComponentIconCell="ParentSeparatorIconCell";
				MenuSeparatorCssClasses.ComponentOver="ParentSeparatorOver";
				MenuSeparatorCssClasses.ComponentContentCellOver="ParentSeparatorContentCellOver";
				// add the classes names to the collection
				mainEM.CSSClassesCollection.Add(MenuSeparatorCssClasses);

				// add the items for the menu
				mainEM.AddItem(new MenuItem("item1", "Item 1", "", "", "", ""));
				mainEM.AddSeparator("mainMenuSeparator1", "&nbsp;");
				mainEM.AddItem(new MenuItem("item2", "Item 2", "", "", "", ""));
				mainEM.AddSeparator("mainMenuSeparator2", "&nbsp;");
				mainEM.AddItem(new MenuItem("item3", "Item 3", "", "", "", ""));
				mainEM.AddSeparator("mainMenuSeparator3", "&nbsp;");
				mainEM.AddItem(new MenuItem("item4", "Item 4", "", "", "", ""));
				mainEM.AddSeparator("mainMenuSeparator4", "&nbsp;");
				mainEM.AddItem(new MenuItem("item5", "Item 5", "", "", "", ""));

				// add the menu to the placeholder on the page
				placeHolder1.Controls.Add(mainEM);


				// Create the submenus
				em_1 = new EasyMenu();
				em_1.ID = "Easymenu1";
				// this will attach to the first item of the parent menu (id=item1)
				em_1.AttachTo = "item1";
				em_1.StyleFolder = "styles/horizontal7";
				em_1.Width = "140";
				// it will show on mouse over
				em_1.ShowEvent = MenuShowEvent.MouseOver;
				// and will align under the item to which it is attached
				em_1.Align = MenuAlign.Under;
				em_1.OffsetVertical = -2;
				// here are this menu's items
				em_1.AddItem(new MenuItem("menuItem1", "SubItem 1", "", "", "", "alert('Item 1 - SubItem 1')"));
				em_1.AddItem(new MenuItem("menuItem2", "SubItem 2", "", "", "", "alert('Item 1 - SubItem 2')"));
				em_1.AddItem(new MenuItem("menuItem3", "SubItem 3", "", "", "", "alert('Item 1 - SubItem 3')"));
				em_1.AddItem(new MenuItem("menuItem4", "SubItem 4", "", "", "", "alert('Item 1 - SubItem 4')"));
				em_1.AddItem(new MenuItem("menuItem5", "SubItem 5", "", "", "", "alert('Item 1 - SubItem 5')"));

				// and so on for every submenu
				em_2 = new EasyMenu();
				em_2.ID = "Easymenu2";
				em_2.AttachTo = "item2";
				em_2.StyleFolder = "styles/horizontal7";
				em_2.Width = "140";
				em_2.ShowEvent = MenuShowEvent.MouseOver;
				em_2.Align = MenuAlign.Under;
				em_2.OffsetVertical = -2;
				em_2.AddItem(new MenuItem("menuItem6", "SubItem 1", "", "", "", "alert('Item 2 - SubItem 1')"));
				em_2.AddItem(new MenuItem("menuItem7", "SubItem 2", "", "", "", "alert('Item 2 - SubItem 2')"));
				em_2.AddItem(new MenuItem("menuItem8", "SubItem 3", "", "", "", "alert('Item 2 - SubItem 3')"));

				em_4 = new EasyMenu();
				em_4.ID = "Easymenu4";
				em_4.AttachTo = "item4";
				em_4.StyleFolder = "styles/horizontal7";
				em_4.Width = "140";
				em_4.OffsetVertical = -2;
				em_4.ShowEvent = MenuShowEvent.MouseOver;
				em_4.Align = MenuAlign.Under;
				em_4.AddItem(new MenuItem("menuItem9", "SubItem 1", "", "", "", "alert('Item 4 - SubItem 1')"));
				em_4.AddItem(new MenuItem("menuItem10", "SubItem 2", "", "", "", "alert('Item 4 - SubItem 2')"));

				em_5 = new EasyMenu();
				em_5.ID = "Easymenu5";
				em_5.AttachTo = "item5";
				em_5.StyleFolder = "styles/horizontal7";
				em_5.Width = "140";
				em_5.OffsetVertical = -2;
				em_5.ShowEvent = MenuShowEvent.MouseOver;
				em_5.Align = MenuAlign.Under;
				em_5.AddItem(new MenuItem("menuItem11", "SubItem 1", "", "", "", "alert('Item 5 - SubItem 1')"));
				em_5.AddItem(new MenuItem("menuItem12", "SubItem 2", "", "", "", "alert('Item 5 - SubItem 2')"));
				em_5.AddItem(new MenuItem("menuItem13", "SubItem 3", "", "", "", "alert('Item 5 - SubItem 3')"));
				em_5.AddItem(new MenuItem("menuItem14", "SubItem 4", "", "", "", "alert('Item 5 - SubItem 4')"));
				em_5.AddItem(new MenuItem("menuItem15", "SubItem 5", "", "", "", "alert('Item 5 - SubItem 5')"));

				em_6 = new EasyMenu();
				em_6.ID = "Easymenu6";
				em_6.AttachTo = "menuItem3";
				em_6.StyleFolder = "styles/horizontal7";
				em_6.Width = "140";
				em_6.ShowEvent = MenuShowEvent.MouseOver;
				em_6.Align = MenuAlign.Right;
				em_6.OffsetVertical = 0;
				em_6.OffsetHorizontal = -4;
				em_6.AddItem(new MenuItem("menuItem31", "SubItem 1", "", "", "", "alert('Item 1 - SubItem 3 - SubItem 1')"));
				em_6.AddItem(new MenuItem("menuItem32", "SubItem 2", "", "", "", "alert('Item 1 - SubItem 3 - SubItem 2')"));
				em_6.AddItem(new MenuItem("menuItem33", "SubItem 3", "", "", "", "alert('Item 1 - SubItem 3 - SubItem 3')"));

				// add the submenus to the page
				placeHolder1.Controls.Add(em_1);
				placeHolder1.Controls.Add(em_2);
				placeHolder1.Controls.Add(em_4);
				placeHolder1.Controls.Add(em_5);
				placeHolder1.Controls.Add(em_6);
			}
		}
    private void Page_Load(object sender, System.EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            string          sConnectionString;
            OleDbDataReader oReader;

            // The database has 2 tables, Menus for the principal menus and MenuItems for the items
            // Each Menu has an ID, and each item of that menu must have the same MENUID so they can be related
            // The Menu that has no ATTACHTO property set in the database is the main menu (parent)
            // and is the one that has ShowEvent set to Always. This has to be the first menu to add on the page
            // hence we order by ATTACHTO field first.
            sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Page.Server.MapPath("../App_Data/DBDEMO_horizontal.mdb");
            OleDbConnection Cn  = new OleDbConnection(sConnectionString);
            string          SQL = "SELECT * FROM Menus a Inner Join MenuItems b ON (a.ID = b.MENUID) ORDER BY a.ATTACHTO, a.ID, b.ORDER";
            OleDbCommand    Com = new OleDbCommand(SQL, Cn);
            Cn.Open();
            oReader = Com.ExecuteReader();
            string   lastMenuId = "";
            EasyMenu oem        = null;

            // Populate EM in one loop.
            while (oReader.Read())
            {
                // Initialising a new EM
                if (oReader.GetString(oReader.GetOrdinal("menuID")) != lastMenuId)
                {
                    oem             = (EasyMenu)Page.Session["EasyMenu_" + oReader.GetString(oReader.GetOrdinal("menuid"))];
                    oem.Position    = MenuPosition.Horizontal;
                    oem.Width       = "140";
                    oem.IconsFolder = "Icons";
                    oem.StyleFolder = oReader.GetString(oReader.GetOrdinal("style"));

                    // if an attachto property is set, this is not the main menu
                    if (!oReader.IsDBNull(oReader.GetOrdinal("attachto")))
                    {
                        oem.ShowEvent = MenuShowEvent.MouseOver;

                        if (oem.AttachTo != "item1" && oem.AttachTo != "item2" && oem.AttachTo != "item3")
                        {
                            oem.Align = MenuAlign.Right;
                        }
                        else
                        {
                            oem.Align = MenuAlign.Under;
                        }

                        oem.Position = MenuPosition.Vertical;
                    }
                    // otherwise this is the main menu
                    else
                    {
                        oem.ShowEvent = MenuShowEvent.Always;
                        oem.Width     = "400px";
                    }
                }

                // Adding either a Separator or an Item
                if (oReader.GetString(oReader.GetOrdinal("ITEMTYPE")) == "S")
                {
                    oem.AddSeparator(oReader.GetString(oReader.GetOrdinal("b.ID")), oReader.IsDBNull(oReader.GetOrdinal("HTML")) ? "" : oReader.GetString(oReader.GetOrdinal("HTML")));
                }
                else if (oReader.GetString(oReader.GetOrdinal("ITEMTYPE")) == "I")
                {
                    oem.AddMenuItem(oReader.GetString(oReader.GetOrdinal("b.ID")), oReader.IsDBNull(oReader.GetOrdinal("HTML")) ? "" : oReader.GetString(oReader.GetOrdinal("HTML")), oReader.IsDBNull(oReader.GetOrdinal("ICON")) ? "" : oReader.GetString(oReader.GetOrdinal("ICON")), oReader.IsDBNull(oReader.GetOrdinal("URL")) ? "" : oReader.GetString(oReader.GetOrdinal("URL")), oReader.IsDBNull(oReader.GetOrdinal("URLTARGET")) ? "" : oReader.GetString(oReader.GetOrdinal("URLTARGET")), oReader.IsDBNull(oReader.GetOrdinal("ONCLIENTCLICK")) ? "" : oReader.GetString(oReader.GetOrdinal("ONCLIENTCLICK")));
                }

                lastMenuId = oReader.GetString(oReader.GetOrdinal("menuID"));
            }

            oReader.Close();
            Cn.Close();
        }
    }