TreeView SiteMapDataSource

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I am using VB.Net version 2 in a web application. I have a Navigation
TreeView that is powered by a SiteMapDataSource linked to Web.sitemap file.
This all works well.

My questions is, how can I programatically hide a node based upon user roles?

Thanks.
 
Hi Gerhard,

Regarding on this issue, I've also met some similar request before.
Actually, the ASP.NET 2.0 Sitemap provider based navigation engine does
allow us to do some dynamic customization on the sitemap structure that
will be displayed. Here are some possible means you can use:

1. If you're using the sitemappath control and want to hide the current
navigating path, you can use the following approach:

#How to: Programmatically Modify Site-Map Nodes in Memory
http://msdn2.microsoft.com/en-us/library/ms178425(VS.80).aspx

2. If you want to customize multiple navigation nodes(in Treeview or
Menu....), you may consider use the NodeDataBoundd events. In such event,
you can get each Node when it has been bound to data and you can choose to
change their Node properties(such as Text, NavigationUrl....). Thus, you
can change those Nodes(you do not want to display based on current user
role) to a fixed Text though you can not completely remove it. I've
provided some demo code snippet in the following thread:

http://groups.google.com/group/microsoft.public.dotnet.framework.aspnet/brow
se_thread/thread/7e646764510649c6/2cb15f1cce88d372

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



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

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

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


This posting is provided "AS IS" with no warranties, and confers no rights.
 
Thanks. I'm now able to "hide" what I want by setting the text to "", but it
looks messy as there is a blank row in the tree...

Is there a way to change what file the SiteMapDataSource uses
programatically? Right now it runs off of Web.sitemap. Based on roles, can
I point it to Web2.sitemap? I don't see any properties that allow me to do
that.

Thanks.
 
Hi Gerhard,

Thanks for your quick response.

Yes, put "" as Node Text will make the user experience not well, instead
you can display such Node's text as "Unauthroized or Protected Path..." so
as to indicate the user.

In addition, if you do want to customize the complete siteMap Tree (node
hierarchy), so far what I can get is create your own SiteMapProvider, at
least customize the default XmlSiteMapProvider. It has some methods you can
override which handle the sitemap tree creation. Here is a former thread
I've discussed on this:

#editing web.sitemap programatically Options
http://groups.google.com/group/microsoft.public.dotnet.framework.aspnet/brow
se_thread/thread/d7b7f68858f2c828/d7c6940de9d73d82

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 
Thanks.

I ended up making two copies of the web.sitemap and copying the one I wanted
to web.sitemap based on roles (file copy). Seems a bit round about, but at
least it is working. Not knowing C#, the examples would have taken too much
time to decipher.

Thanks for your help.
 
Back
Top