473,398 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

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.Remove(Menu1.FindItem("Administration" ))

But this does not remove it's child item

Menu1.Items.Remove(Menu1.FindItem("Administration/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 28771
On Jul 10, 2:32 pm, Larry Bud <larrybud2...@yahoo.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.Remove(Menu1.FindItem("Administration" ))

But this does not remove it's child item

Menu1.Items.Remove(Menu1.FindItem("Administration/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("Administration/Activities").Enable=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.remove".

Jeppe Jespersen
Denmark
>
This removed a root level item:

Menu1.Items.Remove(Menu1.FindItem("Administration" ))

But this does not remove it's child item

Menu1.Items.Remove(Menu1.FindItem("Administration/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.remove".
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.remove".

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 XmlSiteMapProvider variations.

securityTrimmingEnabled 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**********@yahoo.comwrote in message
news:11**********************@q75g2000hsh.googlegr oups.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.Remove(Menu1.FindItem("Administration" ))

But this does not remove it's child item

Menu1.Items.Remove(Menu1.FindItem("Administration/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
>
Thanks, and I may switch to this, but any idea on why I can't remove a
child item?
Hmm.... tried reproducing your problem, but wasn't able to.
But have you tried something like:

Menu1.FindItem("Fish").ChildItems.Clear()
Menu1.Items.Remove(Menu1.FindItem("Fish"))

-Jeppe
Jul 11 '07 #11
Hi Larry,
Dont know if you have a solution yet or not but I test the Text property
of the menuitem to "" this had the effect of removing the menu entry. Hope
this help.

Cheers

Vinnie

"Larry Bud" wrote:
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.Remove(Menu1.FindItem("Administration" ))

But this does not remove it's child item

Menu1.Items.Remove(Menu1.FindItem("Administration/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.

Sep 18 '07 #12
try this:

MenuItem menuItemAdmin = menuMain.FindItem("Administration");
MenuItem menuItemActivities = menuMain.FindItem("Administration/Activities");
menuItemAdmin.ChildItems.Remove(menuItemActivities );
"Larry Bud" wrote:
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.Remove(Menu1.FindItem("Administration" ))

But this does not remove it's child item

Menu1.Items.Remove(Menu1.FindItem("Administration/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.

Nov 29 '07 #13
"Larry Bud" wrote:
Trying to conditionally remove menu items of the 2.0 .NET menuitem
control and I'm stumped.
This removed a root levelitem:
Menu1.Items.Remove(Menu1.FindItem("Administration" ))
But this does notremoveit's childitem
Menu1.Items.Remove(Menu1.FindItem("Administration/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 themenuitemstill appears.
What am I doing wrong? Thx.- Hide quoted text -

On Nov 29 2007, 5:14*pm, hepek <he...@discussions.microsoft.com>
wrote:
try this:

MenuItem menuItemAdmin = menuMain.FindItem("Administration");
MenuItem menuItemActivities = menuMain.FindItem("Administration/Activities");
menuItemAdmin.ChildItems.Remove(menuItemActivities );
Thanks, this worked!
Jan 7 '08 #14

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

Similar topics

4
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...
1
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...
4
by: Yuk Cheng | last post by:
<<<start index.htm>>> <html> <head> <script> function perform(action){ } </script> </head>
2
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...
0
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...
1
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,...
1
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: ...
13
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...
0
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...
0
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...
0
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,...

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.