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

Home Posts Topics Members FAQ

TreeView SiteMapDataSour ce

Hi,

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

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

Thanks.
Jul 19 '07 #1
4 3166
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: Programmaticall y Modify Site-Map Nodes in Memory
http://msdn2.microsoft.com/en-us/lib...25(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/micro...rk.aspnet/brow
se_thread/thread/7e646764510649c 6/2cb15f1cce88d37 2

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

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

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.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/subscripti...t/default.aspx.

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

Jul 20 '07 #2
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 SiteMapDataSour ce 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.

"Steven Cheng[MSFT]" wrote:
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: Programmaticall y Modify Site-Map Nodes in Memory
http://msdn2.microsoft.com/en-us/lib...25(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/micro...rk.aspnet/brow
se_thread/thread/7e646764510649c 6/2cb15f1cce88d37 2

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

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

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.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/subscripti...t/default.aspx.

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

Jul 20 '07 #3
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 "Unauthroiz ed 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 XmlSiteMapProvi der. 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/micro...rk.aspnet/brow
se_thread/thread/d7b7f68858f2c82 8/d7c6940de9d73d8 2

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.



Jul 20 '07 #4
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.

"Steven Cheng[MSFT]" wrote:
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 "Unauthroiz ed 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 XmlSiteMapProvi der. 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/micro...rk.aspnet/brow
se_thread/thread/d7b7f68858f2c82 8/d7c6940de9d73d8 2

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.



Jul 20 '07 #5

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

Similar topics

3
5196
by: Mark | last post by:
I can envision a situation where I want part of our site to be navigated using a TreeView, and ALL of our site to have a Breadcrumb (SiteMapPath control). Is there a way to maintain a single SiteMaptDataSource (Web.sitemap) for both, but only have 1/2 of the nodes visible in the TreeControl, and have ALL the nodes visible in the Breadcrumb? We could maintain two Web.sitemaps, but that sounds like a annoying maintenance issue. Thanks...
6
1713
by: Alan Silver | last post by:
Hello, I want to show a treeview display of the contents of a sitemap file on another web site, chosen according to the currently logged on user. I know at run time the path to the sitemap file, but this cannot be determined at design time as it depends who logs in. Can I do this? I can't see how without writing my own provider, which seems like a lot of work for such a simple request?
0
343
by: Gerhard | last post by:
I am using the following code: <asp:Panel Runat="server" id="pnlNavigation" CssClass="pnlNavigation" Width="165px"> <asp:TreeView ID="TreeView1" runat="server" DataSourceID="SiteMapDataSource1" CssClass="nav" BorderStyle="None" CollapseImageToolTip="" ExpandImageToolTip="" ShowExpandCollapse="False"> <LevelStyles> <asp:TreeNodeStyle CssClass="homenav" Font-Underline="False" />
3
11220
by: Gerhard | last post by:
I have the following code in an .net 2.0 project: <asp:Panel Runat="server" id="pnlNavigation" CssClass="pnlNavigation" Width="165px"> <asp:TreeView ID="TreeView1" runat="server" DataSourceID="SiteMapDataSource1" CssClass="nav" BorderStyle="None" CollapseImageToolTip="" ExpandImageToolTip="" ShowExpandCollapse="False"> <LevelStyles> <asp:TreeNodeStyle CssClass="homenav" Font-Underline="False" />
2
1159
by: Matt | last post by:
I have below sitemap as source for treeview that sits on master pages.. Is there a way to limit source for treeview to page level.. When i cruise the pages i would like to see only related nodes for that page versus see all nodes in every page Example would be.. A.aspx would show only a.aspx b.aspx instead of showing all tree.....?
1
2453
by: James Coleman | last post by:
I am using the TreeView control in ASP.NET 2.0 and like it. However, our sitebuilders aren't too pleased with the idea of the table that gets rendered. They are big into avoiding <table> tags when it comes to site build. So is there a way I could have the following html be rendered from the treeview control? <div class="rightNavHighlight"><a href="#">Ergonomics</a></div> <div class="rightNavHighlight"><a href="#">Environmental
0
1988
by: noneya22 | last post by:
I want to use a TreeView control as a one-level, vertical navigation menu. I'm using this control currently with a SiteMapDataSource and .sitemap file. I've written code that associates an image with each TreeView node based upon a custom attribute I have included in the siteMapNode nodes of my .sitemap file. This all works as desired, including the security trimming which is especially desired behavior. The nodes of the TreeView...
1
4875
by: =?Utf-8?B?QnJpYW4=?= | last post by:
I have a master page that contains a simple treeview populated using a SiteMapDataSource so the data is static. Here is my problem. When I expand the menu to show the 2nd level treeview items and then click on one to move to the selected page, when the new page is displayed the treeview has reverted back to it's original non-expanded state. What is the best way to maintain the expanded/collapsed state of the master page treeview while...
0
1305
by: vingomail | last post by:
Good Morning, I have two site map: "common.sitemap, loginuser.sitemap", two master page:" common.master, loginuser.master", in common.master, there is a Navigation control: TreeView TreeView--- Sitemapdatasource---common.sitemap in Loginuser.master, there is another Navigation control: TreeView TreeView---sitemapdatasource---loginuser.sitemap
0
8386
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
8901
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
8814
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
7415
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...
1
6213
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4390
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2799
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2041
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1792
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.