How to hide some map nodes from menu

S

Shimon Sim

I have web.sitemap file that is used in sitemappath control. I also have a
menu that uses the same sitemap file. is it possible to "hide" some nodes
from menu but still have them available for SiteMapPath control.
I need it since some pages could be displayed only if the have some
parameters passed to them via url.
Thank you,
Shimon.
 
S

S. Justin Gengo

Simon,

Use the OnMenuItemDataBound event and you can check which node you're on by
looking at the menu item's text.

Protected Sub Menu1_MenuItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.MenuEventArgs) Handles Menu1.MenuItemDataBound

Try

If e.Item.Text = "Page2" Then
'---Don't show page2
e.Item.Text = ""
End If

Catch ex As Exception

ProcessException("There was an error during menu creation:", ex)

End Try

End Sub

--
S. Justin Gengo
Web Developer / Programmer

Free code library:
http://www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
S

Shimon Sim

OK.
This is kind of solution.
Is there a way to do this just by using sitemap file? This way it will be
easier to manage the whole thing.
Thanks.
 
S

Steven Cheng[MSFT]

Hi Shimon,

So far I think Justin's suggestion would be preferred since that approach
just focus on the Menu control's rendering. And actually the task you need
to do require the customization on multiple layers from sitemap provider to
site map controls. the default Site map provider(xml file) only support
show/hide nodes depend on role setting. If you want to do it at
configuration file level and make the visibility different between
different controls, we need to customize both the sitemapprovider and the
certain site map controls.

Regards,

Steven Cheng
Microsoft Online Community Support


==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.
 
Joined
May 16, 2006
Messages
27
Reaction score
0
Menu1_DataBound

Simon,

Use Menu1_DataBound event,

for e.g.

Protected Sub Menu1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles Menu1.DataBound
' Locate the parent menu of the menuitem to be deleted.
' You can use Menu1.FindItem to find the parent menu.
Menu1.Items(1).ChildItems(3).ChildItems.RemoveAt(1)
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top