CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 6/16/2005 2:47:13 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 13 Views: 131 Favorited: 0 Favorite
14 Items, 1 Pages 1 |< << Go >> >|
aarnott
Asp.Net User
Hide SiteMapNode from Menu control6/16/2005 2:47:13 PM

0

I have pages in my site that users are directed to through Response.Redirect's and Server.Transfer's as the result of certain operations.  Therefore, these pages should not show up in the navigation control Menu.  But I want this pages in the Web.sitemap file so that when the pages are visited the SiteMapPath control displays properly.  How can I hide these pages that should not be navigated to by the user from the Menu control?

Andrew L Arnott
.NET Compact Framework
bitmask
Asp.Net User
Re: Hide SiteMapNode from Menu control6/17/2005 4:09:09 AM

0

Hello aarnott,

One approach I can think of is to take the nodes out of the web.sitemap file,
and add them dynamically when the user arrives at the page using the SiteMap.SiteMapResolve
event.
Dave Sussman
Asp.Net User
Re: Hide SiteMapNode from Menu control6/17/2005 8:27:36 AM

0

It's a common scenario and easily handled using the MenuItemDataBound event. Here's an example from one of my sites:

Protected Sub MyMenu_MenuItemDataBound(ByVal sender As Object, _
                                       ByVal e As System.Web.UI.WebControls.MenuEventArgs)

    Dim text As String = e.Item.Text

    If text = "Checkout" Or text = "Shop Item" Or text = "Shopping Cart" Then
        e.Item.Parent.ChildItems.Remove(e.Item)
    End If

End Sub

Dave

aarnott
Asp.Net User
Re: Hide SiteMapNode from Menu control6/17/2005 9:31:06 PM

0

 bitmask wrote:
Hello aarnott,

One approach I can think of is to take the nodes out of the web.sitemap file,
and add them dynamically when the user arrives at the page using the SiteMap.SiteMapResolve
event.


That sounds like it might work.  Too bad it's so hard-coded.  It would be nice if I could just set an attribute on the siteMapNode in the sitemap file.

 Dave Sussman wrote:
e.Item.Parent.ChildItems.Remove(e.Item)


That unfortunately will not work for me, since my Menu control only displays children nodes, and therefore every node has no e.Item.Parent, apparently.  I get a NullReferenceException.

Thanks for your ideas, both of you. I'm sure Dave's idea works for the majority of the cases.  I've just got a weird case.

Andrew L Arnott
.NET Compact Framework
bitmask
Asp.Net User
Re: Hide SiteMapNode from Menu control6/18/2005 1:32:04 AM

0

Yes - Dave's idea is a good one.

Actually - you are on to something aarnott - you can put your own custom attributes on a siteMapNode and pull them out with an indexer. Combine this with Dave's approach and you have it made.

See: http://weblogs.asp.net/dannychen/archive/2005/03/28/396099.aspx for an example, Danny is adding a custom _target attribute.
Dave Sussman
Asp.Net User
Re: Hide SiteMapNode from Menu control6/18/2005 11:13:42 AM

0

That'sa much better idea - custom attributes. I didn't think of that, and it's far neater than hand coding. I'm going to change mine right away, and then persuade the other book author to rewrite their bit of the navigation chapter.

Andrew, if you only have top level items then they still have a parent - the siteMapNode always has a single parent root node.

Dave
bleroy
Asp.Net User
Re: Hide SiteMapNode from Menu control6/21/2005 2:49:25 AM

0

If it's a top-level node, you can still remove it via Menu.Items.Remove.
If I may ask, why do you use a menu control for a hierarchy that's only one level deep? Wouldn't something like a DataList be more appropriate and less expensive?
Bertrand
----
This posting is provided "AS IS" with no warranties, and confers no rights.
aarnott
Asp.Net User
Re: Hide SiteMapNode from Menu control6/21/2005 4:22:08 AM

0

 bleroy wrote:
If it's a top-level node, you can still remove it via Menu.Items.Remove.

Awesome.  I'll give that a try.
 bleroy wrote:
If I may ask, why do you use a menu control for a hierarchy that's only one level deep? Wouldn't something like a DataList be more appropriate and less expensive?

You know, I have almost no experience with the XmlSiteMapProvider (or whatever it is), and I didn't know a DataList would work.  That sounds pretty promising.  I'll check it out.  Are their any samples I can check out?

Thanks for the suggestions!  

Andrew L Arnott
.NET Compact Framework
bleroy
Asp.Net User
Re: Hide SiteMapNode from Menu control6/21/2005 9:18:48 PM

0

Sure:

<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
<asp:DataList ID="DataList1" runat="server" DataSourceID
="SiteMapDataSource1">
  <ItemTemplate
>
    Description:
    <asp:Label ID="DescriptionLabel" runat="server" Text='<%# Eval("Description") %>'></asp:Label><br
/>
    Title:
    <asp:Label ID="TitleLabel" runat="server" Text='<%# Eval("Title") %>'></asp:Label><br
/>
    Url:
    <asp:Label ID="UrlLabel" runat="server" Text='<%# Eval("Url") %>'></asp:Label><br
/>
  </ItemTemplate
>
</asp:DataList>


Bertrand
----
This posting is provided "AS IS" with no warranties, and confers no rights.
aarnott
Asp.Net User
Re: Hide SiteMapNode from Menu control6/22/2005 11:06:51 PM

0

Thanks for that code snippet.  Two questions:
  1. I want to put this menu (DataList) in a bulleted list, and without the table that it produces by default.  How can I get DataList1 to produce ONLY what I have inside the ItemTemplate so I can put <LI> tags around each item and nothing else? (no table tags)
  2. I still need to prevent certain nodes in the siteMap from appearing in the DataList.  I've read the link earlier in this topic, and it talks about handling the ItemDataBound event, but that is for carrying custom attributes over to links, rather than removing those links altogether.  So far, every method I can find for removing a node turns up a "collection is read only" exception.  Any ideas?
Thanks. 

Andrew L Arnott
.NET Compact Framework
bleroy
Asp.Net User
Re: Hide SiteMapNode from Menu control6/23/2005 12:17:55 AM

0

If you need total control over the rendering, just use a Repeater instead of the datalist.
To remove a node from the sitemap data source, you can write your own derived data source, or you can use the built-in security trimming feature where you limit some nodes to some roles.
Bertrand
----
This posting is provided "AS IS" with no warranties, and confers no rights.
Bill Mild
Asp.Net User
Re: Hide SiteMapNode from Menu control2/10/2006 3:02:38 AM

0

Found this post from 6 montsh ago.  This is exactly what I need to do: write my own derived data source which will allow me to programatically remove a SiteMapNode.  I have some situations where the security trimmings does not cut it.  But, I'm not real good at figuring out this kind of stuff.  How does one write this derived data source?
Dave Sussman
Asp.Net User
Re: Hide SiteMapNode from Menu control2/10/2006 9:18:47 AM

0

What you write depend on wher eyou need to do this filtering. There are two UI controls: the SiteMapDataSource, which exposes site map data for display to bound controls (menus, treeviews, lists, etc), and the SiteMapPath, which is the breadcrumbs. If you have a need to have the site map data filtered for both then you need to work at the provider level, and there are sample providers available in the Provider toolkit (http://msdn.microsoft.com/asp.net/downloads/providers/default.aspx). If you only need the menu filtering you could just write a new menu control - I have one (along with a provider) at http://www.ipona.com/samples/MS%20Vienna%20-%20ASP.NET%202.0%20Navigation.zip.

Also make sure sure you check out Betrand and Danny's blogs: http://weblogs.asp.net/bleroy/ and http://weblogs.asp.net/dannychen/.

Dave

Bill Mild
Asp.Net User
Re: Hide SiteMapNode from Menu control2/10/2006 3:11:57 PM

0

Hi Dave,

Thanks for all that information.  I took a look at your site and the blogs and the provider toolkit.  I don't know why, but when I look custom control code, I freeze up like a deer in the road staring at oncoming car headlights.  Unfortunately, I fear I need to get better at custom control code.  In the web app I am writing, I am binding the SiteMap to a DataList.  What I think I'm looking for, is to write a new DataList control which will expose a way to filter out specific SiteMapNodes from ItemDataBound or another event.

14 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Beginning ASP.NET 3.5: In C# and VB Authors: Imar Spaanjaars, Pages: 734, Published: 2008
ASP.NET 2.0: Your Visual Blueprint for Developing Web Applications Authors: Chris Love, Pages: 339, Published: 2007
Visual Web Developer 2005 express edition for dummies Authors: Alan Simpson, Pages: 358, Published: 2005
Core Internet application development with ASP.NET 2.0 Authors: Randy Connolly, Pages: 1049, Published: 2007
Beginning ASP.NET 2.0 in VB 2005: from novice to professional Authors: Matthew MacDonald, Pages: 1063, Published: 2006

Web:
Hide SiteMapNode from Menu control - ASP.NET Forums Re: Hide SiteMapNode from Menu control ... That unfortunately will not work for me, since my Menu control only displays children nodes, ...
Hide SiteMapPath Nodes??? - ASP.NET Forums Check this: Hide SiteMapNode from Menu control. http://forums.asp.net/thread/ 1194119.aspx. Although it is about the asp.net menu control, ...
Possible to hide siteMapNode from menu? Talk about Possible to hide siteMapNode from menu? ... In the SiteMapPath control, I want the two pages do display as follows (which, works) ...
Small spacer pixel inserted in ASP.NET menu control? How to remove? 2.0 menu control. It works, but it seems to insert a small visible pixel-spacer immediately above the menu ... ... Show quoteHide quote. > Hello, ...
Menu By default the SiteMapDataSource control returns all SiteMapNode items for display and the Menu defaults to display a single static level of data, ...

Treeview hide sitemap node... - ng.asp-net-forum ... Treeview hide sitemap node..., > ROOT > NEWSGROUP > Asp.Net Forum ... This way you can control what is being shown or not shown. .... How can i hide the node in the menu but keep the menu in the page if you know what i . ...
Hide SiteMapPath Nodes??? - ng.asp-net-forum ... Check this: Hide SiteMapNode from Menu control. http://forums.asp.net/thread/ 1194119.aspx. Although it is about the asp.net menu control, ...
Hide SiteMapNode??? - ng.asp-net-forum ... Hide SiteMapNode from Menu control - ASP.NET Forums Actually - you are on to something aarnott - you can put your own custom attributes on a siteMapNode and ...
How to pass array in place of string title in SiteMapNode with ... Close() End Try ' Return the root SiteMapNode Return _root End SyncLock End .. ... some questions on integrating sitemap and menu control ...
how to do this with SiteMapNode ?? - ng.asp-net-forum ... how to do this with SiteMapNode ??, > ROOT > NEWSGROUP > Asp.Net Forum ... Treeview hide sitemap node... - ng.asp-net-forum ... I have a Sitemap with SiteMapNodes ... inserting a script to control image using html module ...






content disappear with menu control when using divs

response.flush causes page to loose theme ???

menu

alternating header navigation

modify / remove items from web.sitemap

how to change the name of the treeview category in order to pass as a parameter to sql procedure?

how to stop a treeview from flashing after clicking a node?

selected menu item

lost ability to edit content pages

using dropdowns in master page to display results in detail page gridview

2.0 navigation menu issues

problems with skins when dynamically loading custom controls

char between menuitems

multi language with themes

row height

setting a theme at runtime

master page, response.redirect and viewstate

creating a master page afterwards

accessing controls from masterpage

asp:button not working in content page when updatepanel in masterpage, why?

script to close internet explorer after web application has ran

arranging items in menu control

the following code give an error

sitemap problem

masterpage / content holder / problem

masterpages or dreamweaver templates - which works best?

menu control help needed

referencing javascript in master page

menu control -selected node

problem centering table inside an contentplaceholder on masterpage

   
  Privacy | Contact Us
All Times Are GMT