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); } }
private void RecursivelyPopulateMenuSubCategory(DataRow dbRow, EasyMenu parentMenuItem, DataSet ds,int rows,int columns) { string ParentId = dbRow["CategoryId"].ToString(); //if( dbRow["CategoryId"].ToString().ToLower()=="") if (dbRow.GetChildRows("NodeRelation").Length > 0 && columns > 0) { // parentMenuItem.AttachTo = category; // parentMenuItem.Visible = true; parentMenuItem.Align = MenuAlign.Under; parentMenuItem.Position = MenuPosition.Horizontal; parentMenuItem.ShowEvent = MenuShowEvent.MouseOver; parentMenuItem.UseIcons = true; parentMenuItem.OffsetHorizontal = 10; parentMenuItem.ZIndex = 400; parentMenuItem.ExpandStyle = ExpandStyle.Slide; //parentMenuItem.EventList = "OnAfterMenuClose"; //parentMenuItem.ID = "mynewid"; if (columns >= 2) parentMenuItem.RepeatColumns = columns; parentMenuItem.Width = (120 * columns).ToString(); string iconPath = "~/Images/home/"; iconPath = iconPath.Replace("~", ""); parentMenuItem.IconsFolder = iconPath; OboutInc.EasyMenu_Pro.MenuItem miDepart = new OboutInc.EasyMenu_Pro.MenuItem("Departments", "    ", "departments.jpg", "", "", "");//<span id=\"departments\">departments</span> miDepart.Disabled = true; // miDepart.Visible = false; OboutInc.EasyMenu_Pro.MenuItem miSplit = new OboutInc.EasyMenu_Pro.MenuItem("Split", "    ", "split.png", "", "", ""); miSplit.Disabled = true; parentMenuItem.AddItemAt(0, miDepart); parentMenuItem.AddItemAt(1, miSplit); int DepartNo = 0; foreach (DataRow childRow in dbRow.GetChildRows("NodeRelation")) { DepartNo++; if (DepartNo <= rows) { string itemText = childRow["Name"].ToString(); string categoryId = childRow["CategoryId"].ToString(); string seoURL = childRow["SEOURL"].ToString(); seoURL = ZNodeSEOUrl.MakeURL(categoryId, SEOUrlType.Category, seoURL); string categoryText = itemText; categoryText = categoryText.Replace(" ", ""); parentMenuItem.AddMenuItem(categoryText, "<span id=\"menu_item\">" + itemText + "</span>", "arrow.png", seoURL, "", ""); } } if (DepartNo > rows) { string ceva = "Departments"; string callback = "for (i = 0; i < ob_em_mynewid.items.length; i++){alert(ob_em_mynewid.items[i].id)}"; parentMenuItem.AddMenuItem("ViewAll1", "<span id=\"view_all\">View All...</span>", "", "", "", "displaymessage(ob_em_subMenu4," + ceva + ")"); } if (columns > 1) { OboutInc.EasyMenu_Pro.MenuItem miBrand = new OboutInc.EasyMenu_Pro.MenuItem("Brand", "    ", "brands.jpg", "", "", "");//<span id=\"brand\">brands</span> miBrand.Disabled = true; OboutInc.EasyMenu_Pro.MenuItem miSplit2 = new OboutInc.EasyMenu_Pro.MenuItem("Split2", "    ", "split.png", "", "", ""); miSplit2.Disabled = true; parentMenuItem.AddItemAt(1, miBrand); parentMenuItem.AddItemAt(1 + columns, miSplit2); int BrandNo = 0; string newID = ""; foreach (DataRow childRow in ds.Tables[0].Rows) { string itemText = childRow["ManufacturerName"].ToString(); string categoryId = childRow["CategoryId"].ToString(); string seoURL = " ";// = childRow["SEOURL"].ToString(); // seoURL = ZNodeSEOUrl.MakeURL(categoryId, SEOUrlType.Category, seoURL); string categoryText = itemText; categoryText = categoryText.Replace(" ", ""); newID = categoryText+BrandNo.ToString(); //newID = newID.Replace(" ",""); if (categoryId == ParentId && BrandNo + 1 <= rows) { //parentMenuItem.AddMenuItem(categoryText, itemText, "arrow.png", seoURL, "", ""); parentMenuItem.AddMenuItemAt((BrandNo + 1) * 2 - 1, newID, "<span id=\"menu_item\">" + itemText + "</span>", "arrow.png", seoURL, "", ""); BrandNo++; } } if (BrandNo > rows) parentMenuItem.AddMenuItem("ViewAll2", "<b>View All...</b>", "", "", "", ""); } if (columns > 2) { string categoryName=dbRow["Name"].ToString().ToLower(); if (categoryName == "eyeglasses" || categoryName == "sunglasses") { string imagePath = "~/Images/home/"; imagePath = imagePath.Replace("~", ""); string itemText = "<a href=\"ceva\" onmouseover=\"roll_over('" + categoryName + "clip_on" + "', '" + imagePath + "clip_on_over.jpg" + "')\" onmouseout=\"roll_over('" + categoryName + "clip_on" + "', '" + imagePath + "clip_on.jpg" + "')\" ><img border=\"0\" name =\"" + categoryName + "clip_on" + "\" src=\"" + imagePath +"clip_on.jpg"+ "\"/>"; parentMenuItem.AddMenuItemAt(2, categoryName + "clip_on", itemText, "", "", "", ""); itemText = "<a href=\"ceva\" onmouseover=\"roll_over('" + categoryName + "goggles" + "', '" + imagePath + "goggles_over.jpg" + "')\" onmouseout=\"roll_over('" + categoryName + "goggles" + "', '" + imagePath + "goggles.jpg" + "')\" ><img border=\"0\" name =\"" + categoryName + "goggles" + "\" src=\"" + imagePath + "goggles.jpg" + "\"/>"; parentMenuItem.AddMenuItemAt(5, categoryName + "goggles", itemText, "", "", "", ""); itemText = "<a href=\"ceva\" onmouseover=\"roll_over('" + categoryName + "readers" + "', '" + imagePath + "readers_over.jpg" + "')\" onmouseout=\"roll_over('" + categoryName + "readers" + "', '" + imagePath + "readers.jpg" + "')\" ><img border=\"0\" name =\"" + categoryName + "readers" + "\" src=\"" + imagePath + "readers.jpg" + "\"/>"; parentMenuItem.AddMenuItemAt(8, categoryName + "readers", itemText, "", "", "", ""); /*itemText = "<a href=\"ceva\" ><img border=\"0\" name =\"" + categoryName + "build" + "\" src=\"" + imagePath + "build_custom.jpg" + "\"/>"; parentMenuItem.AddMenuItemAt(11, categoryName + "build", itemText, "", "", "", "");*/ itemText = "<a href=\"ceva\" ><img border=\"0\" name =\"" + categoryName + "build1" + "\" src=\"" + imagePath + "build_custom1.jpg" + "\"/>"; parentMenuItem.AddMenuItemAt(11, categoryName + "build1", itemText, "", "", "", ""); itemText = "<a href=\"ceva\" ><img border=\"0\" name =\"" + categoryName + "build2" + "\" src=\"" + imagePath + "build_custom2.jpg" + "\"/>"; parentMenuItem.AddMenuItemAt(14, categoryName + "build2", itemText, "", "", "", ""); itemText = "<a href=\"ceva\" ><img border=\"0\" name =\"" + categoryName + "build3" + "\" src=\"" + imagePath + "build_custom3.jpg" + "\"/>"; parentMenuItem.AddMenuItemAt(17, categoryName + "build3", itemText, "", "", "", ""); } } } }
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(); } }