當前位置: 首頁>>代碼示例>>C#>>正文


C# WebControls.MenuItemCollection類代碼示例

本文整理匯總了C#中System.Web.UI.WebControls.MenuItemCollection的典型用法代碼示例。如果您正苦於以下問題:C# MenuItemCollection類的具體用法?C# MenuItemCollection怎麽用?C# MenuItemCollection使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MenuItemCollection類屬於System.Web.UI.WebControls命名空間,在下文中一共展示了MenuItemCollection類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: DeluxeMenu

        /// <summary>
        /// PopupMenu構造函數
        /// </summary>
        /// <remarks></remarks>
		public DeluxeMenu()
            : base(true, HtmlTextWriterTag.Div)
        {
            this.items = new MenuItemCollection(null);
            //this.Style.Add("Width", "0");

        }
開發者ID:jerryshi2007,項目名稱:AK47Source,代碼行數:11,代碼來源:DeluxeMenu.cs

示例2: BuildItems

        private void BuildItems(HtmlTextWriter writer, MenuItemCollection items, bool isRoot = false)
        {
            if (items.Count <= 0)
            {
                return;
            }

            string cssClass = "submenu";

            if (isRoot)
            {
                cssClass = "nav sidebar-menu";
                if (!string.IsNullOrEmpty(this.CssClass))
                {
                    cssClass += " " + this.CssClass;
                }
            }

            writer.AddAttribute(HtmlTextWriterAttribute.Class, cssClass);
            writer.RenderBeginTag(HtmlTextWriterTag.Ul);

            if (isRoot)
                items = items[0].ChildItems;

            foreach (MenuItem item in items)
            {
                this.BuildItem(writer, item);
            }

            writer.RenderEndTag(); // </ul>
        }
開發者ID:viniciusrlopes,項目名稱:LTM.Dashboard,代碼行數:31,代碼來源:SideBarMenu.cs

示例3: FindSelectedItem

		MenuItem FindSelectedItem(MenuItemCollection items)
		{
			foreach (MenuItem item in items)
			{
				if (item.NavigateUrl.Length > 0 && Request.Path.Contains(item.NavigateUrl.Replace("~", "")))
				{
					return item;
				}
				MenuItem childSelected = FindSelectedItem(item.ChildItems);
				if (childSelected != null)
					return childSelected;
			}
			return null;
		}
開發者ID:gbahns,項目名稱:Tennis,代碼行數:14,代碼來源:Tennis.Master.cs

示例4: BindMenu

        public void BindMenu(MenuItemCollection items)
        {
            if ((PackageId <= 0) || (ItemID <= 0))
                return;

            //Organization menu group;
            if (Cntx.Groups.ContainsKey(ResourceGroups.HostedOrganizations))
                PrepareOrganizationMenuRoot(items);

            //Exchange menu group;
            if (Cntx.Groups.ContainsKey(ResourceGroups.Exchange))
                PrepareExchangeMenuRoot(items);

            //BlackBerry Menu
            if (Cntx.Groups.ContainsKey(ResourceGroups.BlackBerry))
                PrepareBlackBerryMenuRoot(items);

            //SharePoint menu group;
            if (Cntx.Groups.ContainsKey(ResourceGroups.SharepointFoundationServer))
                PrepareSharePointMenuRoot(items);

            if (Cntx.Groups.ContainsKey(ResourceGroups.SharepointEnterpriseServer))
                PrepareSharePointEnterpriseMenuRoot(items);

            //CRM Menu
            if (Cntx.Groups.ContainsKey(ResourceGroups.HostedCRM2013))
                PrepareCRM2013MenuRoot(items);
            else if (Cntx.Groups.ContainsKey(ResourceGroups.HostedCRM))
                PrepareCRMMenuRoot(items);

            //OCS Menu
            if (Cntx.Groups.ContainsKey(ResourceGroups.OCS))
                PrepareOCSMenuRoot(items);

            //Lync Menu
            if (Cntx.Groups.ContainsKey(ResourceGroups.Lync))
                PrepareLyncMenuRoot(items);

            //EnterpriseStorage Menu
            if (Cntx.Groups.ContainsKey(ResourceGroups.EnterpriseStorage))
                PrepareEnterpriseStorageMenuRoot(items);

            //Remote Desktop Services Menu
            if (Cntx.Groups.ContainsKey(ResourceGroups.RDS))
                PrepareRDSMenuRoot(items);
        }
開發者ID:JohnyBuchar,項目名稱:Websitepanel,代碼行數:46,代碼來源:OrganizationMenuControl.cs

示例5: PopulateNodes

        private void PopulateNodes(DataTable dt, MenuItemCollection items)
        {
            foreach (DataRow dr in dt.Rows)
            {
                MenuItem mi = new MenuItem();

                mi.Text = dr["menu"].ToString();
                mi.Value = dr["menuid"].ToString();
                mi.NavigateUrl = dr["url"].ToString();
                items.Add(mi);
                //If node has child nodes, then enable on-demand populating
                bool flag = ((int)(dr["childnodecount"]) > 0);
                if (flag)
                {
                    menuCreate(mi);
                }
            }
        }
開發者ID:tianhang,項目名稱:SA39_AD,代碼行數:18,代碼來源:Site.Master.cs

示例6: QuitarItems

        private void QuitarItems(MenuItemCollection items)
        {
            MenuItem[] itemsToRemove = new MenuItem[items.Count];
            int i = 0;
            if (UsuarioLogueado.TipoPersona == Persona.TiposPersonas.Alumno)
            {
                foreach (MenuItem item in items)
                {
                    if((item.Value=="Alumno") || (item.Value=="Ambos"))
                    {
                        if (item.ChildItems.Count > 0) QuitarItems(item.ChildItems);
                    }
                    else
                    {
                        itemsToRemove[i] = item;
                        i++;
                    }
                }
                for (int j = 0; j < i; j++)
                {
                    items.Remove(itemsToRemove[j]);
                }
            }

            if (UsuarioLogueado.TipoPersona == Persona.TiposPersonas.Docente)
            {
                foreach (MenuItem item in items)
                {
                    if ((item.Value == "Profesor") || (item.Value == "Ambos"))
                    {
                        if (item.ChildItems.Count > 0) QuitarItems(item.ChildItems);
                    }
                    else
                    {
                        itemsToRemove[i] = item;
                        i++;
                    }
                }
                for (int j = 0; j < i; j++)
                {
                    items.Remove(itemsToRemove[j]);
                }
            }
        }
開發者ID:serasio,項目名稱:TP2,代碼行數:44,代碼來源:MenuPpal.aspx.cs

示例7: RemovePermissaoMenu

        public void RemovePermissaoMenu(MenuItemCollection items)
        {
            ISeguranca iseguranca = Factory.GetInstance<ISeguranca>();
            IList<int> indices = new List<int>();
            for (int i = items.Count - 1; i >= 0; i--)
            {
                if (items[i].ChildItems.Count > 0)
                {
                    RemovePermissaoMenu(items[i].ChildItems);
                }

                if (items[i].Value != "EMPTY" && !iseguranca.VerificarPermissao(((ViverMais.Model.Usuario)Session["Usuario"]).Codigo, items[i].Value.Split(':')[0].ToString(), int.Parse(items[i].Value.Split(':')[1].ToString())))
                {
                    indices.Add(i);
                }
            }
            foreach (int i in indices)
            {
                items.RemoveAt(i);
            }
        }
開發者ID:vivermais,項目名稱:vivermais,代碼行數:21,代碼來源:MasterMain2.Master.cs

示例8: RenderDropDownMenu

        protected void RenderDropDownMenu(HtmlTextWriter writer, MenuItemCollection items, string submenuClientId)
        {
            writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "none");
            writer.AddStyleAttribute(HtmlTextWriterStyle.Position, "absolute");
            DynamicMenuStyle.AddAttributesToRender(writer);
            writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
            writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0");
            writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
            writer.AddAttribute(HtmlTextWriterAttribute.Id, submenuClientId);
            writer.RenderBeginTag(HtmlTextWriterTag.Table);
            writer.RenderBeginTag(HtmlTextWriterTag.Tr);
            writer.RenderBeginTag(HtmlTextWriterTag.Td);

            for (int i = 0; i < items.Count; i++)
            {
                var childItem = items[i];
                RenderDropDownMenuItem(writer, childItem, submenuClientId, i);
            }

            writer.RenderEndTag();
            writer.RenderEndTag();
            writer.RenderEndTag();
        }
開發者ID:Jeff-Tian,項目名稱:IZWebFileManager,代碼行數:23,代碼來源:BaseMenu.cs

示例9: BuildItems

        private void BuildItems(MenuItemCollection items, bool isRoot, HtmlTextWriter writer)
        {
            if (items.Count > 0)
            {
                writer.WriteLine();

                writer.WriteBeginTag("ul");
                if (isRoot)
                {
                    writer.WriteAttribute("class", "navig twolevel");
                }
                writer.Write(HtmlTextWriter.TagRightChar);
                writer.Indent++;

                foreach (MenuItem item in items)
                {
                    BuildItem(item, writer);
                }

                writer.Indent--;
                writer.WriteLine();
                writer.WriteEndTag("ul");
            }
        }
開發者ID:tmthang-bi,項目名稱:BrokerManager,代碼行數:24,代碼來源:MenuAdapter.cs

示例10: MenuItemCollectionEnumerator

 internal MenuItemCollectionEnumerator(MenuItemCollection list) {
     this.list = list;
     this.index = -1;
     version = list._version;
 }
開發者ID:nlh774,項目名稱:DotNetReferenceSource,代碼行數:5,代碼來源:MenuItemCollection.cs

示例11: RenderMenuBody

		void RenderMenuBody (HtmlTextWriter writer, MenuItemCollection items, bool vertical, bool dynamic)
		{
			if (!vertical) writer.RenderBeginTag (HtmlTextWriterTag.Tr);
			
			for (int n=0; n<items.Count; n++) {
				MenuItem item = items [n];
				if (n > 0) {
					Unit itemSpacing = GetItemSpacing (item, dynamic);
					if (itemSpacing != Unit.Empty) {
						if (vertical) {
							writer.AddAttribute ("height", itemSpacing.ToString());
							writer.RenderBeginTag (HtmlTextWriterTag.Tr);
							writer.RenderEndTag ();
						} else {
							writer.AddAttribute ("width", itemSpacing.ToString());
							writer.RenderBeginTag (HtmlTextWriterTag.Td);
							writer.RenderEndTag ();
						}
					}
				}
				RenderMenuItem (writer, item);
			}
			
			if (!vertical) writer.RenderEndTag ();	// TR
		}
開發者ID:jjenki11,項目名稱:blaze-chem-rendering,代碼行數:25,代碼來源:Menu.cs

示例12: RenderMenu

		void RenderMenu (HtmlTextWriter writer, MenuItemCollection items, bool vertical, bool dynamic, int menuLevel)
		{
			RenderMenuBeginTag (writer, dynamic, menuLevel);
			RenderMenuBody (writer, items, vertical, dynamic);
			RenderMenuEndTag (writer);
		}
開發者ID:jjenki11,項目名稱:blaze-chem-rendering,代碼行數:6,代碼來源:Menu.cs

示例13: LoadNavigation

        /// <summary>
        /// Loops through the list items in the MyNiem List and gets the navigation based on access.
        /// </summary>
        /// <param name="List"></param>
        protected void LoadNavigation(SPList List)
        {
            try
            {
                if (Page.User.Identity.IsAuthenticated)
                {
                    SPListItemCollection Items = List.Items;
                    var PersonalNav = LoginView1.FindControl("PersonalNav") as AspMenu;
                    MenuItemCollection MenuItems = new MenuItemCollection();

                    //grabs the items in the list then loops through the webs the user currently has access too
                    foreach (SPListItem Item in Items)
                    {
                        //old code to recursively check if the user has access to the subweb
                        //if (Web.Url.ToLower() == SPContext.Current.Web.Site.RootWeb.Url.ToLower() + "/" + Item["Title"].ToString().ToLower())
                        //    FoundWeb = true;
                        //else
                        //    FoundWeb = GetSubWebs(Web, SPContext.Current.Web.Site.RootWeb.Url.ToLower() + "/" + Item["Title"].ToString().ToLower(), FoundWeb);
                        //Guid SiteGuid = SPContext.Current.Site.ID;
                        string SiteURL = SPContext.Current.Web.Site.RootWeb.Url.ToLower();
                        SPUser CurrentUser = SPContext.Current.Web.CurrentUser;
                        SPSecurity.RunWithElevatedPrivileges(delegate()
                        {
                            #region OldCode
                            //    if (FoundWeb)
                            //    {
                            //        using (SPSite Site = new SPSite(SPContext.Current.Web.Site.RootWeb.Url.ToLower() + "/" + Item["Title"].ToString()))
                            //        {
                            //            using (SPWeb FoundSubWeb = Site.OpenWeb())
                            //            {
                            //                MenuItem MyNiemItem = new MenuItem(FoundSubWeb.Title, FoundSubWeb.Title, "", FoundSubWeb.Url);
                            //                int CompareNumber = 0;
                            //                for(int i=0;i<MenuItems.Count && CompareNumber>=0;i++)
                            //                {
                            //                    string CompareItem = MyNiemItem.Text;
                            //                    CompareNumber = CompareItem.CompareTo(MenuItems[i].Text);
                            //                    if(CompareNumber < 0)
                            //                        MenuItems.AddAt(i, MyNiemItem);
                            //                }
                            //                if(CompareNumber>=0)
                            //                    MenuItems.Add(MyNiemItem);
                            //                FoundWeb = false;
                            //            }
                            //        }
                            //    }
                            //}
                            //foreach (MenuItem Item in MenuItems)
                            //{
                            //    PersonalNav.Items.Add(Item);
                            //}
                            #endregion

                            //new code to check against site
                            using (SPSite Site = new SPSite(SiteURL + "/" + Item["Title"].ToString()))
                            {
                                using (SPWeb Web = Site.OpenWeb())
                                {
                                    if (Web.DoesUserHavePermissions(CurrentUser.LoginName, SPBasePermissions.Open))
                                    {
                                        MenuItem MyNiemItem = new MenuItem(Web.Title, Web.Title, "", Web.Url);
                                        int CompareNumber = 0;
                                        for (int i = 0; i < MenuItems.Count && CompareNumber >= 0; i++)
                                        {
                                            string CompareItem = MyNiemItem.Text;
                                            CompareNumber = CompareItem.CompareTo(MenuItems[i].Text);
                                            if (CompareNumber < 0)
                                                MenuItems.AddAt(i, MyNiemItem);
                                        }
                                        if (CompareNumber >= 0)
                                            MenuItems.Add(MyNiemItem);
                                    }
                                }
                            }

                        });
                    }
                    foreach (MenuItem Item in MenuItems)
                    {
                        PersonalNav.Items.Add(Item);
                    }
                }
            }
            catch (SPException ex)
            {
                UpdateErrorLog(ex);
            }
        }
開發者ID:NIEM-Web,項目名稱:Sharepoint,代碼行數:91,代碼來源:PersonalMenu.ascx.cs

示例14: BuildItems

        private void BuildItems(MenuItemCollection items, bool isRoot, HtmlTextWriter writer)
        {
            if (items.Count > 0)
            {
                writer.WriteLine();

                writer.WriteBeginTag("ul");
                if (isRoot)
                {
                    if (!string.IsNullOrEmpty(Control.CssClass))
                    {
                        writer.WriteAttribute("class", Control.CssClass);
                    }
                    if (Control.ID != "SubNavMenu")
                    {
                        writer.WriteAttribute("id", Control.ID);
                    }
                }
                else if (_nextingLevel < Control.StaticDisplayLevels)
                {
                    writer.WriteAttribute("style", "position: relative !important; visibility: visible !important;");
                }
                else if (items[0].Parent.Text == "Contact Us")
                {
                    writer.WriteAttribute("style", "width: 128px !important;");
                }
                writer.Write(HtmlTextWriter.TagRightChar);
                writer.Indent++;

                foreach (MenuItem item in items)
                {
                    BuildItem(item, writer);
                }

                writer.Indent--;
                writer.WriteLine();
                writer.WriteEndTag("ul");
            }
        }
開發者ID:brandongrossutti,項目名稱:DotCopter,代碼行數:39,代碼來源:MenuAdapter.cs

示例15: GetIconsDataSource

        public MenuItemCollection GetIconsDataSource(int packageId)
        {
            // load package context
            PackageContext cntx = PackagesHelper.GetCachedPackageContext(packageId);

            // init collection
            MenuItemCollection items = new MenuItemCollection();

            // get icons list
            foreach (XmlNode xmlNode in xmlIcons)
            {
                // create icon item
                MenuItem iconItem = CreateMenuItem(cntx, xmlNode);
                if (iconItem == null)
                    continue;

                // add into list
                items.Add(iconItem);
            }

            return items;
        }
開發者ID:lwhitelock,項目名稱:Websitepanel,代碼行數:22,代碼來源:UserSpaces.ascx.cs


注:本文中的System.Web.UI.WebControls.MenuItemCollection類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。