Hide an ASP.NET Menu Item - asp.net

I have an ASP.NET webforms application with a Menu control. How does one hide a particular menu item via code? I've seen a few articles pointing out how to do it with ASP.Net membership/roles-based security, but this particular use case has nothing to do with that. I simply need a way to programmatically remove a menu item from code. Any help would be appreciated.

It would be more straight forward to use
myMenu.Items.RemoveAt(0);
This will remove the first menuitem
myMenu.Items[0].ChildItems.RemoveAt(1);
This will remove the second child of the fist menuitem
myMenu.Items[0].ChildItems[1].ChildItems.RemoveAt(1)
This will remove the second child of the second child of the fist menuitem

Doh! Ok, I figured it out. The correct syntax is (VB.Net):
mnuMyMenu.Items.Remove(mnuMyMenu.Items(1))

myMenu.Items(0).ChildItems.Remove(myMenu.Items(0).ChildItems(1))

If you want to remove a menu item by the menu item Text property, you can use:
myMenu.Items.Remove(myMenu.FindItem("Item Text"))

Related

Is there a way of disabling a WKInterfaceMenu?

I have a WKInterfaceMenu added to the storyboard which is working great. However, once used, I don't want the menu to appear for a second time.
Is there a way of preventing the menu from appearing?
You can definitely do this, but you need to do things a bit differently.
First off, don't set up the context menu in the storyboard. Instead, set up all the menu items programmatically. You can add and remove menu items using the addMenuItemWithImageNamed and clearAllMenuItems methods on your WKInterfaceController instance.
You want to set up all your menu items initially, then remove them in all your callback methods for each menu item. That way, they'll be there at first, and will be removed once you select one of them.

Remove some Child Items from Menu Control in ASP.NET

I know this is a very common question asked. However, I have looked all over and couldn't find a good answer that will work for my scenario.
I have a MainMenu which has SubMenus. I need to remove some items from Submenus not all.
I can easily remove items from MainMenu by using
MainMenu.Items.Remove(e.Item) in Databound event of the Menu
ForExample in following menu how can I remove sub2 from Main2 Menu.
Main1-
Main2->sub1,sub2
My Menu is bound to SiteMap.
I have tried e.Item.ChildItems.RemoveAt(0), but e.Item.ChildItems.Count for Main2 is 0.
I don't know how to solve this.
Please help.
If your menu is bound to SiteMap and you want to remove items, don't you need to make a new map and bind to that?

Flex form inside Pop up window - Tab (order) between forms not working

when user clicks on Add button, then a pop up button will be opened with certain form elements (like textinput, date field, text area).. When i used 'TAB' inside this form,it is not working. I found in couple of Questions / forums that we need to create an instance of FocusManager and then bring/activate focus for the pop up. But still i didn't see the tab working inside the form. In order to tab order working inside a pop up, what steps we need to follow.
I tried using focusmanager and property like tabfocusenabled, tabenabled and also added taborder inside each form element. But no luck.
Iam using Flash Builder 4.5 and using spark components for development.
Is there any workaround for this problem?
Thanks in Advance,
Regards
Srinivasan
Thanks for all your responses.
Finally the issue has been solved by one of my colleague. Problem is , the form has been loaded inside Horizontal accordion (flexlib HACCORDION). So inorder to draw focus inside the accordion to child elements, we need to add 'hasFocusableChildren="true"' for the HAccordion (horizontal accordion component). Adding this property solves the tab order problem.
I have also pasted the code below:

How to hide an ASP.NET menu item?

This question was asked before but what I need is to simply hide a menu Item rather than remove it . I was surprised to see that ASp.NET MenuItem has no Visible property. is there any way really yo hide a menu Item
Thanks
you can hide the menu item using css. just use CssClass property. Using CSS and Styles with the Menu Control
I ran into the same issue and my work around was actually having two separate menus. I assigned my Admin controls that i wanted to hide in its own menu. I positioned them next to eachother as if they are one and i hide the menu when the user doesn't have access in my codebehind.

Editing an asp.net DropdownList

I have a dropdown list of 5 elements. My problem is that I want to make this dropdown list editable. Basically a user might want to delete one of these elements or might want to add more elements. Whats a good approach of doing that in asp.net ?
Use a ComboBox.
You have to put textbox for typing text and button for user to insert into the list and button for delete
Do you know the code to adding and deleting list in the dropdown list right ?
Use a ListBox - that way they can make a multi-selection of their choice:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listbox.aspx
The DropDownList is not intended for multi-selection. Another option would be to use CheckBoxes.
If you use DataBase, u can make dropdownlist MORE editable with elements like "formView", "gridView" and so on..

Resources