473,671 Members | 2,473 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Removing Menu Items and Child Menu Items

Trying to conditionally remove menu items of the 2.0 .NET menu item
control and I'm stumped.

This removed a root level item:

Menu1.Items.Rem ove(Menu1.FindI tem("Administra tion"))

But this does not remove it's child item

Menu1.Items.Rem ove(Menu1.FindI tem("Administra tion/Activities"))

No errors are thrown, and FindItem *IS* finding Administration/
Activities value path. I'm using the default value path separator of
the forward slash, but the menu item still appears.

What am I doing wrong? Thx.

Jul 10 '07 #1
13 28798
On Jul 10, 2:32 pm, Larry Bud <larrybud2...@y ahoo.comwrote:
Trying to conditionally remove menu items of the 2.0 .NET menu item
control and I'm stumped.

This removed a root level item:

Menu1.Items.Rem ove(Menu1.FindI tem("Administra tion"))

But this does not remove it's child item

Menu1.Items.Rem ove(Menu1.FindI tem("Administra tion/Activities"))

No errors are thrown, and FindItem *IS* finding Administration/
Activities value path. I'm using the default value path separator of
the forward slash, but the menu item still appears.

What am I doing wrong? Thx.
Just a little more info:
Menu1.FindItem( "Administra tion/Activities").En able=false

DOES disable the menu item. So why can't I remove it?

Jul 10 '07 #2
Hi Larry,
Trying to conditionally remove menu items of the 2.0 .NET menu item
control and I'm stumped.
Why do you want to do this? I'd like to know, as there might be a smarter
way than "items.remo ve".

Jeppe Jespersen
Denmark
>
This removed a root level item:

Menu1.Items.Rem ove(Menu1.FindI tem("Administra tion"))

But this does not remove it's child item

Menu1.Items.Rem ove(Menu1.FindI tem("Administra tion/Activities"))

No errors are thrown, and FindItem *IS* finding Administration/
Activities value path. I'm using the default value path separator of
the forward slash, but the menu item still appears.

What am I doing wrong? Thx.

Jul 10 '07 #3
On Jul 10, 3:21 pm, "Jeppe Jespersen" <jdj at jdj dot dkwrote:
Hi Larry,
Trying to conditionally remove menu items of the 2.0 .NET menu item
control and I'm stumped.

Why do you want to do this? I'd like to know, as there might be a smarter
way than "items.remo ve".
To hide menu items based on a User's role.

There's no "visible" property, and the Enable flag is just plain ugly.

Jul 10 '07 #4
>Why do you want to do this? I'd like to know, as there might be a smarter
way than "items.remo ve".

To hide menu items based on a User's role.
Have you looked into the "security trimming" property on (i believe) the
SiteMapProvider ?
Using this, you define in the web.config file what pages (and therefore
menuitems) are visible/accessible to which users.

It's pretty late here (in Euroland) $now, but I'll whip up an example
tomorrow if you want?

Jeppe Jespersen
Denmark
Jul 10 '07 #5
Hi, me again.

Check out this MSDN article. Let me know if this is what you want.
....and if the article helped :-)

Jeppe

Jul 10 '07 #6

Here is an interesting read:
http://www.alexthissen.nl/blogs/main...-sitemaps.aspx
Or search for custom XmlSiteMapProvi der variations.

securityTrimmin gEnabled is the other item of interest.
The top URL is about rights (not roles), but it should lead you to the place
you want to go.

"Larry Bud" <la**********@y ahoo.comwrote in message
news:11******** **************@ q75g2000hsh.goo glegroups.com.. .
Trying to conditionally remove menu items of the 2.0 .NET menu item
control and I'm stumped.

This removed a root level item:

Menu1.Items.Rem ove(Menu1.FindI tem("Administra tion"))

But this does not remove it's child item

Menu1.Items.Rem ove(Menu1.FindI tem("Administra tion/Activities"))

No errors are thrown, and FindItem *IS* finding Administration/
Activities value path. I'm using the default value path separator of
the forward slash, but the menu item still appears.

What am I doing wrong? Thx.

Jul 10 '07 #7
On Jul 10, 4:24 pm, "Jeppe Jespersen" <jdj at jdj dot dkwrote:
Hi, me again.

Check out this MSDN article. Let me know if this is what you want.
...and if the article helped :-)

Jeppe
Thanks, but you didn't post a link!

Jul 11 '07 #8
>
Thanks, but you didn't post a link!
Oops :-)
Here you go....
http://msdn2.microsoft.com/en-us/lib...28(vs.80).aspx

Jeppe
Jul 11 '07 #9
On Jul 10, 11:43 pm, "Jeppe Jespersen" <jdj at jdj dot dkwrote:
Thanks, but you didn't post a link!

Oops :-)
Here you go....http://msdn2.microsoft.com/en-us/lib...28(vs.80).aspx

Jeppe
Thanks, and I may switch to this, but any idea on why I can't remove a
child item?

Jul 11 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3833
by: JesusFreak | last post by:
From: us_traveller@yahoo.com (JesusFreak) Newsgroups: microsoft.public.scripting.jscript Subject: toolbar script problem NNTP-Posting-Host: 192.92.126.136 Recently, I downloaded the following beautiful script "http://javascript.internet.com/navigation/toolbar-menu.html". It works like a charm. I made my webpage in frames, where the nav-frame shows the menubar, so whenever I click a link in the menubar, it opens in the frame below. But...
1
4316
by: ajay | last post by:
I have following code for a slide menu but i twiked it to work for a single level menu. Open it in a Browser to get a clear picture. I have 2 Qs 1) How to make first entry as non-link. i.e i want to make first text as Table Heading/menu category. For examle in the given menu i want to make a heading as "Comp. Languages" which won't be a link. 2) The position of this menu is absolute to the page. I want to make it absolute to the Table...
4
5764
by: Yuk Cheng | last post by:
<<<start index.htm>>> <html> <head> <script> function perform(action){ } </script> </head>
2
3877
by: Jackson Yap | last post by:
can someone kind enough to help me look at the attached html and js file? Why is it that the javascript menu could not work at www.apchosting.net but could work at http://home.pacific.net.sg/~jacksony ? (the drop down bar could not work at www.apchosting.net but can drop at home.pacific.net.sg. I suspect it is a server problem but was told it is not possible, therefore assuming it is a client script problem? the script works last time...
0
2216
by: Karthick Kumar | last post by:
Hi, I need to create a simple parent/child hierarchical menu. I have alread used the Treeview control but my requirement is slightly different than the Treeview control. I already have the kind of menu I am talking about, written in Classic ASP, but I need to write the entire menu thing in Asp.Net using CSharp. I have a Sql table which has large number of menu items with problemId and parentId, through which I am trying to create and...
1
2158
by: Anthony | last post by:
Below is a script I found at http://javascript.internet.com/ for a cascading menu. The script works great but there is one thing that I would like modified. BecauseI am just learning javascript, I did not want to try to modify the code without a little help. When you place the mouse over the menu bar, this script calls the function to show the menu. I would like it modified to hide the menu when the mouse is removed. Please help. The...
1
6631
by: jobs | last post by:
I have a menu that really does not lend itself to a sitemap datasource or security trimming. In the codebehind i've been able to remove top level menu items with this code: Menu.Items.Remove(Menu.FindItem("Admin")) But how can I remove child menu items under the Admin entry in the same way?
13
2848
by: PetterL | last post by:
I writing a program where I read menu items from a file. But I have problem when I click an menu item i want it to mark that one as checked but I cant access the menu object of that item to see witch object was selected. This is the sub procedure that read the items from an Array and create the menutitem. The array hold more information to use in program when one of the items is selected. Dim finisharray(,) As String ' is set up...
0
8401
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8926
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8824
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8673
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7444
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4416
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2060
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.