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


C# Menu.FindItem方法代碼示例

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


在下文中一共展示了Menu.FindItem方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: SetearOpcionesConsultor

        private void SetearOpcionesConsultor(Menu menuPrincipal)
        {
            SetearOpcionesGeneral(menuPrincipal);

            menuPrincipal.Items.Remove(menuPrincipal.FindItem("Cliente"));

            // Buscar el item Vehiculo
            MenuItem menuVehiculo = menuPrincipal.FindItem("Vehiculo");

            // Buscar cada subitem del item Vehiculo
            MenuItem venderVehiculo = menuPrincipal.FindItem("Vehiculo/VenderVehiculo");
            MenuItem registrarVehiculo = menuPrincipal.FindItem("Vehiculo/RegistrarVehiculo");
            MenuItem modificarVehiculo = menuPrincipal.FindItem("Vehiculo/ModificarVehiculo");
            MenuItem caracteristicasVehiculo = menuPrincipal.FindItem("Vehiculo/CaracteristicasVehiculo");
            MenuItem eliminarVehiculo = menuPrincipal.FindItem("Vehiculo/EliminarVehiculo");

            // Eliminar cada subitem del item Vehiculo
            menuVehiculo.ChildItems.Remove(venderVehiculo);
            menuVehiculo.ChildItems.Remove(registrarVehiculo);
            menuVehiculo.ChildItems.Remove(modificarVehiculo);
            menuVehiculo.ChildItems.Remove(caracteristicasVehiculo);
            menuVehiculo.ChildItems.Remove(eliminarVehiculo);
        }
開發者ID:nMoschen,項目名稱:NET_TP2,代碼行數:23,代碼來源:Home.aspx.cs

示例2: SetearOpcionesGeneral

 private void SetearOpcionesGeneral(Menu menuPrincipal)
 {
     // Remover los items que no son accesibles por el usuario
     menuPrincipal.Items.Remove(menuPrincipal.FindItem("Empleado"));
     menuPrincipal.Items.Remove(menuPrincipal.FindItem("Comision"));
 }
開發者ID:nMoschen,項目名稱:NET_TP2,代碼行數:6,代碼來源:Home.aspx.cs

示例3: DoMenuSelection

        private void DoMenuSelection(Menu menu)
        {
            // TODO: clean up this hairy mess without breaking anything

            MenuItem menuItem = null;
            bool didSelect = false;
            string valuePath;

            if (isSubMenu)
            {
                valuePath = SiteUtils.GetPageMenuActivePageValuePath(pageMapDataSource.Provider.RootNode);
            }
            else
            {
                valuePath = SiteUtils.GetActivePageValuePath(pageMapDataSource.Provider.RootNode, startingNodeOffset, Request.RawUrl);
            }

            if (valuePath.Length > 0)
            {
                menuItem = menu.FindItem(valuePath);

                if (menuItem == null)
                {
                    if (startingNodeOffset > 0)
                    {
                        for (int i = 1; i <= startingNodeOffset; i++)
                        {
                            if (valuePath.IndexOf("|") > -1)
                            {
                                valuePath = valuePath.Remove(0, valuePath.IndexOf("|") + 1);
                            }

                        }
                    }
                }

                if (menuItem == null)
                {
                    valuePath = SiteUtils.GetPageMenuActivePageValuePath(pageMapDataSource.Provider.RootNode);
                    menuItem = menu.FindItem(valuePath);
                }

                if (menuItem != null)
                {
                    try
                    {
                        menuItem.Selected = true;
                        didSelect = true;
                    }
                    catch (InvalidOperationException)
                    {
                        //can happen if node disabled or unselectable
                    }
                }
            }

            if (!didSelect)
            {
                valuePath = SiteUtils.GetActivePageValuePath(pageMapDataSource.Provider.RootNode, startingNodeOffset);

                if (valuePath.Length > 0)
                {

                    menuItem = menu.FindItem(valuePath);

                    if (
                         (menuItem == null)
                         && (valuePath.IndexOf(menu.PathSeparator) > -1)
                        )
                    {
                        valuePath = valuePath.Substring(0, (valuePath.IndexOf(menu.PathSeparator)));
                        menuItem = menu.FindItem(valuePath);
                    }

                    if (
                        (dynamicDisplayLevels == 0)
                        && (menuItem == null)
                        && (valuePath.IndexOf(menu.PathSeparator) > -1)
                        )
                    {

                        foreach (MenuItem m in menu.Items)
                        {
                            if (valuePath.Contains(m.ValuePath))
                            {
                                try
                                {
                                    m.Selected = true;
                                    didSelect = true;
                                }
                                catch (InvalidOperationException)
                                {
                                    //can happen if node disabled or unselectable
                                }
                                return;
                            }

                        }
                    }

//.........這裏部分代碼省略.........
開發者ID:saiesh86,項目名稱:TravelBlog,代碼行數:101,代碼來源:PageMenu.ascx.cs

示例4: DoSelecetion

        private void DoSelecetion(Menu menu)
        {
            if (suppressPageSelection) { return; }
            bool didSelect = false;

            String valuePath = SiteUtils.GetActivePageValuePath(siteMapDataSource.Provider.RootNode, startingNodeOffset, Request.RawUrl);

            if (valuePath.Length > 0)
            {
                MenuItem menuItem;
                menuItem = menu.FindItem(valuePath);

                if (
                    (topLevelOnly || menu.MaximumDynamicDisplayLevels == 0)
                    && (menuItem == null)
                    && (valuePath.IndexOf(menu.PathSeparator) > -1)
                    )
                {
                    valuePath = valuePath.Substring(0, (valuePath.IndexOf(menu.PathSeparator)));
                    menuItem = menu.FindItem(valuePath);
                }

                if (menuItem != null)
                {
                    try
                    {
                        menuItem.Selected = true;
                        didSelect = true;
                    }
                    catch (InvalidOperationException)
                    {
                        //can happen if node disabled or unselectable
                    }
                }

            }

            if (!didSelect)
            {
                valuePath = SiteUtils.GetActivePageValuePath(siteMapDataSource.Provider.RootNode, startingNodeOffset);

                if (valuePath.Length > 0)
                {
                    MenuItem menuItem;
                    menuItem = menu.FindItem(valuePath);

                    if (
                        (topLevelOnly)
                        && (menuItem == null)
                        && (valuePath.IndexOf(menu.PathSeparator) > -1)
                        )
                    {
                        valuePath = valuePath.Substring(0, (valuePath.IndexOf(menu.PathSeparator)));
                        menuItem = menu.FindItem(valuePath);

                        // http://www.mojoportal.com/Forums/Thread.aspx?thread=7277&mid=34&pageid=5&ItemID=5&pagenumber=1#post33725
                        // patch by vijaykarla 2011-05-24
                        // If the page is not Included In Menu, the above line of code wont work (returns null), following code is solution for it
                        //=========
                        if (menuItem == null)
                        {
            #if NET35
                            if (!string.IsNullOrEmpty(valuePath))
            #else
                            if (!string.IsNullOrWhiteSpace(valuePath))
            #endif
                            {
                                int lastSeperatorIndex = valuePath.LastIndexOf(menu.PathSeparator);
                                while (lastSeperatorIndex > 0)
                                {
                                    valuePath = valuePath.Substring(0, lastSeperatorIndex);
                                    menuItem = menu.FindItem(valuePath);
                                    if (menuItem != null)
                                        break;
                                    lastSeperatorIndex = valuePath.LastIndexOf(menu.PathSeparator);
                                }
                            }
                        }
                        //=======
                    }

                    if (menuItem != null)
                    {
                        try
                        {
                            menuItem.Selected = true;
                            didSelect = true;
                        }
                        catch (InvalidOperationException)
                        {
                            //can happen if node disabled or unselectable
                        }
                    }

                }

            }
        }
開發者ID:joedavis01,項目名稱:mojoportal,代碼行數:98,代碼來源:SiteMenu.ascx.cs

示例5: RemoverMenuItem

 public static void RemoverMenuItem(Menu Menu, string IdMenuItem)
 {
     MenuItem menuItem = Menu.FindItem(IdMenuItem);
     if (menuItem != null) RemoverMenuItem(Menu, menuItem);
 }
開發者ID:pjeconde,項目名稱:CedServicios,代碼行數:5,代碼來源:Funciones.cs


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