当前位置: 首页>>代码示例>>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;未经允许,请勿转载。