Hide/Show items

Jul 30, 2008 at 9:47 AM
Hi,

I've been playing with the MultiMenu webcontrol and I think that is very robust and flexible. It's a good control to use and I want to thank you for it.

But there is one thing that I can't find.

How do I show/hide menu items depending of the user? I  mean, if the user is an Administrator or User or Guest,...

Thanks !

Xavier
Coordinator
Aug 10, 2008 at 12:08 AM
Xavier,

Assign unique tags to all your items in the XML config and use the FindMenuItem(string tag) method to return the item you want to disable or make invisible. Use the Enable property to disable the item or use the Visible property to hide the item.

Bill
Oct 21, 2008 at 4:52 PM
Edited Oct 21, 2008 at 4:55 PM
Hi Bill.

My name is Javier, and like Xavier, I also find Your control very nice.
I'm trying to hide a MenuItem following your instructions, but can't make it work.

MultiMenuItem item = mnuMaster.FindMenuItem("admin");

 

if (item != null)
{
    item.Visible =
false;
}

But the item is always false because the method FindMenuItem didn't find the Item.

This the line in the XML where the tag was assigned: (Line 10)

01    <MenuItem Text="Otros Gastos" PostBack="false">
02       <
MenuGroup Width="120" HorizontalOffset="10">
03            <
MenuItem Text="Registrar" Url="OtrosGastos.aspx"/>
04            <
MenuItem Text="Supervisor" ToolTip="Aprobaciones Supervisor" RightIcon="arrow_r.gif" PostBack="false" >
05                <
MenuGroup Width="120" ExpandDirection="Right" >
06                    <
MenuItem Text="Aprobar" Url="OAprobacionSuper.aspx" PostBack="True" />
07                    <
MenuItem Text="Ver Historia" ToolTip="Consultar Hist¢rico de Aprobaciones" Url="OHistoriaSuper.aspx" PostBack="True" />
08                </
MenuGroup>
09            </
MenuItem>
10            <
MenuItem Text="Administrador" ToolTip="Aprobaciones Administrador" RightIcon="arrow_r.gif" PostBack="false" Tag="admin">
11                <
MenuGroup Width="120" ExpandDirection="Right" >
12                    <
MenuItem Text="Aprobar" Url="OAprobacionAdm.aspx" PostBack="True" />
13                    <
MenuItem Text="Ver Historia" ToolTip="Consultar Hist¢rico de Aprobaciones" Url="OHistoriaAdm.aspx" PostBack="True" />
14                </
MenuGroup>
15            </
MenuItem>
16        </
MenuGroup>
17    </
MenuItem>

Coordinator
Nov 11, 2008 at 8:31 PM
At what point in the page lifecycle are you using FindMenuItem? You might be calling it before the XML is loaded.