.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Hiding ASP.NET menu items

Posted By:      Posted Date: April 14, 2011    Points: 0   Category :ASP.Net

I want to hide a menu item on my master page for all users who dont belong to the 'Managers' role.  Looking at the below page I thought this could be done by enabling security trimming but 'securityTrimmingEnabled="true"' is not in Web.config intellisence and causes an error as does setting it in the sitemap file.  Whats the best way to do this?


View Complete Post

More Related Resource Links

Hiding Menu Items with Role


I have been trying to figure this out for a couple days, but am getting really confused on the many different posts/articles I have read.

I am trying to hide certain menu items based on the users role.

I have a Menu and a SiteMapDataSource on a master page:

<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu"
  EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal"
                    <asp:MenuItem NavigateUrl="~/Homepage.aspx" Text="Home"></asp:MenuItem>
                    <asp:MenuItem NavigateUrl="~/Personal.aspx" Text="People"></asp:MenuItem>
                    <asp:MenuItem NavigateUrl="~/Reports.aspx" Text="Rep

Menu items of Welcome control behaves incorrect in non-IE browsers.


We are using wss 3.0 sp2

I am referring to the welcome control that is part of standard sharepoint pages. This is the in the masterpage. The welcome contrrol has options such as 'sign-in as different user' , 'signout' and so on. When user takes the mouse and tries to click on the sub-menu it doesn't work as if the menu item is not getting focussed (however up/down arrow with keyboard works fine). 

I know that sharepoint sites are not best when viewed with firefox, safari, chrome etc  but is there a fix for this? Is it do with 'z' index setting or something? Can this be fixed through javascript?  

Please share your views/solution.


How to Make CSS for Hyperlinks NOT Affect Menu Items


VWD 2008 Express.

I have the following CSS in my DefaultStyleSheet.css file.  I want this to only apply to text hyperlinks (like links to web sites or email addresses) but NOT to my asp:menu items.  I am finding that although I have defined my asp:menu items in the menu properties, the colors in the text in the menu tabs get overridden by the CSS below.  How can I make this not happen?  Thanks for any help.


{color:#6F928B; text-decoration: none}


{color: #660066;}


Hiding Upload Menu

  Hi All, Welcome to SharePoint Products & Techonologies. How to hide the UPLOAD menu in all the document libraries when the user is at 1st level and 2nd level of the folders in the doc library? Let me know if you have any queries. Thanks & Regards, Kumar.

Menu with Static and Dynamic Menu Items

I need to populate a menu with static and dynamic (at runtime) menu items.  I know this issue has been posted before, but I haven't seen anything with a date newer than 2009. This is what I want to do: <Menu> <Menu.ItemsSource>                     <CompositeCollection>                      <MenuItem Header="Menu Item 1" /> <MenuItem Header="Menu Item 2" /> <MenuItem Header="Menu Item 3" />                         <CollectionContainer Collection="{Binding MyMenuItems}" />                     </CompositeCollection> </Menu.ItemsSource> </Menu>   The posts every where say the issue is that CompositeCollection is not freezable.  Regardless of that arguement, has anyone come up with a good solution.  I don't want to create it all in code behind because it is a decent size menu with separators, etc.  This seems like something that should have been fixed or have a decent work round by now.   Thanks. 

Customize SharePoint Library Menu Items

Hi, In a library with file, the menu items available for any file is: View Properties, Edit Properties, Manage Permissions, Edit in <ApplicationName>, Delete, Send To, Check Out, Workflows, Alert Me . Now, I want to get rid of Edit Properties, Manage Permissions, Edit in <ApplicationName>, Delete, Check Out . Added to this is the need to remove the option in the Actions menu that states "Open With Windows Explorer " and finally the "Upload " menu is to go out. Any JScript for this or a file I need to edit to get this result? I need this because the business wants it out, its bordering on security. ThanksYou've only got one life; help as many people as you can, and enjoy it while it lasts.

Menu Items for SPMenu

Hi All, I have developed application page which contains spgridview. And I have used SPMenuField for displaying menu items for files and folders. What my problem is, for both  files and folders I am getting same menu items. But I need to display different menu items for folders and files based on condition. How can I achieve this? Let me know if you have any queries. Regards, Kumar.

How To Space Menu Items Evenly

I'm using Visual Studio 2008. I have a asp menu in a cell in a table. The menu has 3 items as shown below This works fine however, how do you put more spacing (even spacing) bewteen the items? The items are too close together.   <tr>        <td>        </td>        <td>        <asp:Menu ID="Menu1" runat="server" Orientation="Horizontal"                 style="margin-right: 8px">            <Items>                <asp:MenuItem Text="Home" Value="Home"></asp:MenuItem>                <asp:MenuItem Text="Solutions" Value="Solutions"></asp:MenuItem>                <asp:MenuItem Text="Contact" Value="Contact"></asp:MenuItem>            </Items>  

Creating (hiding/showing) admin menu for my Website?

Hi there!I am currently developing a website for a friend of mine who is a dj. I have a login page, which works fine however i want to inplement a menu that only users with the Administrator role can view. I have done alot of research and i have found ways to stop a user from visiting a page, when they click on it it takes the to the login page. But i want to completely hide the menu from Non Admins. Any suggestions would be greatly Appreciated.Thanks in advanced,Jordan.

After building Installer - Items missing from Menu

Not sure if this is the best or correct forum so please excuse me and let me know where I should be posting my question, thanks. I have built my Windows Forms Application and it works fine... I now have to build an Installer project, which I have done with  reasonable success... EXCEPT FOR... The Menu Group and item do NOT appear in the Menu system.  The Desktop item appears correctly and the structure is there but no menu items appear.  I created the shortcut for the User's Desktop and User's Program Menu. (Using VS2008, C#, .NET 3.51, Access (DB), Forms, Installer project.) What am I missing SquireDude

Collect Menu/Submenu/Popupmenu items

Dear Sir, I am using VS2005 and SQL Server2000 I have a project where lot of Menu/Submenu/Popupmenu items. Now I want to have all Menu/Submenu/Popupmenu items in a list box of the project. I want to do this for create user access control to my project. so that selective group can access selected feature and Menu/Submenu/Popupmenu items. How can I do this ?????? / or is there any other way to control this access????

Is it possible to disable context menu items based on the selection on Treeview

I will have some sort of nodes for a treeview as follows Root |-> some.txt(A text file which was added at runtime) |->Child(child for some.txt) |-> child1(child for child) I designed my context menu with some options as New and Remove What i need is when i righclick on Root, child or child i would like to disable the Remove option

Vertical Align Menu Items when RenderingMode=List


I am having problems getting my Menu Items to align vertically in the middle when I set my rendering mode = list.

aspx code

        <asp:Menu ID="Menu1" runat="server" Orientation="Horizontal" 
            RenderingMode="list" CssClass="AspNet-Menu">
                <asp:MenuItem NavigateUrl="#" Text="Menu 1" Value="Menu 1"></asp:MenuItem>
                <asp:MenuItem NavigateUrl="#" Text="Menu 2" Value="Menu 2"></asp:MenuItem>
                <asp:MenuItem NavigateUrl="#" Text="Menu 3" Value="Menu 3"></asp:MenuItem>

css code for list

/* MENU */

.AspNet-Menu ul li{ width:60px; height:30px; background-color:Silver; vertical-align:middle;}
.AspNet-Menu ul li a
	color: Red;

But if i set the rendering mode to table it works fine...

aspx code

        <asp:Menu ID="Menu1" runat="server" Orientation="Horizontal" 
            RenderingMode="table" CssClass="AspNet-Menu">

Navigate Menu asp Control Add Items (HOW?) c#


I feel like a complete idiot!! :)

I have a asp.net menu control on a default.aspx page

I want to add items to this menu control using the code behind file (C#)

How do I do this?

My menu id is mnuHeader

YES, newB question .. LOL


Thanks for your help in advance!!! 

Dynamically Generated Dynamic Menu Items Width Question


I have the following Menu:

<asp:Menu ID="MainMenu" runat="server" Orientation="Horizontal" 
	DynamicVerticalOffset="2" DynamicHorizontalOffset="2" 
	StaticEnableDefaultPopOutImage="false" DynamicEnableDefaultPopOutImage="false" >
        <StaticMenuItemStyle BackColor="#0099cc" ForeColor="#eeeeee" Font-Names="Arial" Font-Size="11" Height="18" HorizontalPadding="10" VerticalPadding="3"  />
	<StaticHoverStyle BackColor="#336699" ForeColor="#ffffff" Font-Names="Arial" Font-Size="11" />
	<DynamicMenuItemStyle BackColor="#0099cc" ForeColor="#eeeeee" Font-Names="Arial" Font-Size="10" Height="18" 
		HorizontalPadding="10" VerticalPadding="3" />
	<DynamicHoverStyle BackColor="#336699" ForeColor="#ffffff" Font-Names="Arial" Font-Size="10" />					
		<asp:MenuItemBinding DataMember="Item" TextField="Title" />
		<asp:MenuItemBinding DataMember="SubItem" TextField="Title" />						

How to left allign menu items in a menu centralized using div


I have a menu control in asp.net 3.5.  The menu control is centralized in the page using a div. I have written CSS to align menu items to the left... In IE8, the menu items also appear centrally alligned.  However in firefox the menu control is correctly aligned to the centre where as the menu items are aligned to the left.  I want the menu items to be alligned left while the menu control allign to the centre of the page in IE too...

Thanks in advance.


Items from one menu into another menu


I have a menu stored into a session variable (for faster loading compared to retrieving all the information from the database all the time).

I need to take the items (which are in hierarchical order) and bind them to my pre-made menu on the page.

I tried doing all the following and none worked...

menu.Items = sessionmenu.Items
menu.datasource = sessionmenu.datasource
menu = sessionmenu

Any help would be wonderful.

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend