473,399 Members | 2,774 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,399 software developers and data experts.

Menu Control

I have a master page which contains a Menu control and a SiteMapPath control,
both are bound to the same web.sitemap XML file. Say I have 2 pages, Page 1
and Page 2. Now Page 2 can only be accessed after selecting some information
on Page 1 (using a CrossPagePostback). When the user get's to Page 2, the
SiteMapPath control fails to render, obviously because Page 2 isn't in the
web.sitemap file.

If I put Page 2 in the web.sitemap file, it then get's rendered in the Menu
control, which I don't want. So, is there any way to "hide" certain nodes in
a web.sitemap file from the Menu control?

Or is there anyway I can have the SiteMapPath control render properly on
Page 2 whilst not showing it in the Menu control to the user?
Nov 19 '05 #1
4 2640
You're going to have to create a custom SiteMapProvider and override the
IsAccessibleToUser method to provide your custom display logic. The easiest
way would be to derive from the existing XmlSiteMapProvider. Fredrik has
some related sample code:

http://fredrik.nsquared2.com/viewpos...wfeedback=true

-Brock
DevelopMentor
http://staff.develop.com/ballen
I have a master page which contains a Menu control and a SiteMapPath
control, both are bound to the same web.sitemap XML file. Say I have 2
pages, Page 1 and Page 2. Now Page 2 can only be accessed after
selecting some information on Page 1 (using a CrossPagePostback). When
the user get's to Page 2, the SiteMapPath control fails to render,
obviously because Page 2 isn't in the web.sitemap file.

If I put Page 2 in the web.sitemap file, it then get's rendered in the
Menu control, which I don't want. So, is there any way to "hide"
certain nodes in a web.sitemap file from the Menu control?

Or is there anyway I can have the SiteMapPath control render properly
on Page 2 whilst not showing it in the Menu control to the user?


Nov 19 '05 #2
Thanks for the link.

OK, I've tried to create a class inheriting the StaticSiteMapProvider but
only overriding the IsAccessibleToUser method. However, I keep getting a
'Cannot create an abstract class' when I try to run my app.

Imports Microsoft.VisualBasic

Namespace AdamSmithCollege.Web

Public MustInherit Class CustomSiteMapProvider
Inherits SiteMapProvider

Public Overrides Function IsAccessibleToUser(ByVal context As
HttpContext, ByVal node As SiteMapNode) As Boolean
If node Is Nothing Then
Throw New ArgumentNullException("node")
End If

If context Is Nothing Then
Throw New ArgumentNullException("context")
End If

If Not Me.SecurityTrimmingEnabled Then
Return True
End If

If (Not node.Roles Is Nothing) And (node.Roles.Count > 0) Then
Dim role As String
For Each role In node.Roles
If Not String.Equals(role, "*",
StringComparison.InvariantCultureIgnoreCase) Then
Continue For
End If

Return True
Next
End If

Return False
End Function
End Class
End Namespace

<siteMap defaultProvider="CustomSiteMapProvider" enabled="true">
<providers>
<add name="XmlSiteMapProvider"
<add name="CustomSiteMapProvider"
description="This provider overrides the IsAccessibleToUser method."
type="ASC.Web.CustomSiteMapProvider"
securityTrimmingEnabled="true"
siteMapFile="Web.sitemap" />
</providers>
</siteMap>

"Brock Allen" wrote:
You're going to have to create a custom SiteMapProvider and override the
IsAccessibleToUser method to provide your custom display logic. The easiest
way would be to derive from the existing XmlSiteMapProvider. Fredrik has
some related sample code:

http://fredrik.nsquared2.com/viewpos...wfeedback=true

-Brock
DevelopMentor
http://staff.develop.com/ballen
I have a master page which contains a Menu control and a SiteMapPath
control, both are bound to the same web.sitemap XML file. Say I have 2
pages, Page 1 and Page 2. Now Page 2 can only be accessed after
selecting some information on Page 1 (using a CrossPagePostback). When
the user get's to Page 2, the SiteMapPath control fails to render,
obviously because Page 2 isn't in the web.sitemap file.

If I put Page 2 in the web.sitemap file, it then get's rendered in the
Menu control, which I don't want. So, is there any way to "hide"
certain nodes in a web.sitemap file from the Menu control?

Or is there anyway I can have the SiteMapPath control render properly
on Page 2 whilst not showing it in the Menu control to the user?


Nov 19 '05 #3
You've marked your class as "MustInherit" which means you can't create an
instance of it. To use the functionality a further dervived class is necessary.
I suspect you didn't intend this. Just remove the keyword.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Thanks for the link.

OK, I've tried to create a class inheriting the StaticSiteMapProvider
but only overriding the IsAccessibleToUser method. However, I keep
getting a 'Cannot create an abstract class' when I try to run my app.

Imports Microsoft.VisualBasic

Namespace AdamSmithCollege.Web

Public MustInherit Class CustomSiteMapProvider
Inherits SiteMapProvider
Public Overrides Function IsAccessibleToUser(ByVal context As
HttpContext, ByVal node As SiteMapNode) As Boolean
If node Is Nothing Then
Throw New ArgumentNullException("node")
End If
If context Is Nothing Then
Throw New ArgumentNullException("context")
End If
If Not Me.SecurityTrimmingEnabled Then
Return True
End If
If (Not node.Roles Is Nothing) And (node.Roles.Count > 0)
Then
Dim role As String
For Each role In node.Roles
If Not String.Equals(role, "*",
StringComparison.InvariantCultureIgnoreCase) Then
Continue For
End If
Return True
Next
End If
Return False
End Function
End Class
End Namespace
<siteMap defaultProvider="CustomSiteMapProvider" enabled="true">
<providers>
<add name="XmlSiteMapProvider"
<add name="CustomSiteMapProvider"
description="This provider overrides the IsAccessibleToUser
method."
type="ASC.Web.CustomSiteMapProvider"
securityTrimmingEnabled="true"
siteMapFile="Web.sitemap" />
</providers>
</siteMap>
"Brock Allen" wrote:
You're going to have to create a custom SiteMapProvider and override
the IsAccessibleToUser method to provide your custom display logic.
The easiest way would be to derive from the existing
XmlSiteMapProvider. Fredrik has some related sample code:

http://fredrik.nsquared2.com/viewpos...howfeedback=tr
ue

-Brock
DevelopMentor
http://staff.develop.com/ballen
I have a master page which contains a Menu control and a SiteMapPath
control, both are bound to the same web.sitemap XML file. Say I have
2 pages, Page 1 and Page 2. Now Page 2 can only be accessed after
selecting some information on Page 1 (using a CrossPagePostback).
When the user get's to Page 2, the SiteMapPath control fails to
render, obviously because Page 2 isn't in the web.sitemap file.

If I put Page 2 in the web.sitemap file, it then get's rendered in
the Menu control, which I don't want. So, is there any way to "hide"
certain nodes in a web.sitemap file from the Menu control?

Or is there anyway I can have the SiteMapPath control render
properly on Page 2 whilst not showing it in the Menu control to the
user?


Nov 19 '05 #4
Hi Brock,

Ooops, never saw that in there!

When I remove the 'MustInherit', I am then told that I must override;

FindSiteMapNode
GetChildNodes
GetParentNode
GetRootNodeCore

I then tried to inherit the XmlSiteMapProvider as this allowed me to only
override the IsAccessibleToUser, but it didn't seem to work as expected.

In the meantime, I've cheated by having 2 sitemaps, 1 for the menu and one
for the SiteMap Control (breadcrumbs).

"Brock Allen" wrote:
You've marked your class as "MustInherit" which means you can't create an
instance of it. To use the functionality a further dervived class is necessary.
I suspect you didn't intend this. Just remove the keyword.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Thanks for the link.

OK, I've tried to create a class inheriting the StaticSiteMapProvider
but only overriding the IsAccessibleToUser method. However, I keep
getting a 'Cannot create an abstract class' when I try to run my app.

Imports Microsoft.VisualBasic

Namespace AdamSmithCollege.Web

Public MustInherit Class CustomSiteMapProvider
Inherits SiteMapProvider
Public Overrides Function IsAccessibleToUser(ByVal context As
HttpContext, ByVal node As SiteMapNode) As Boolean
If node Is Nothing Then
Throw New ArgumentNullException("node")
End If
If context Is Nothing Then
Throw New ArgumentNullException("context")
End If
If Not Me.SecurityTrimmingEnabled Then
Return True
End If
If (Not node.Roles Is Nothing) And (node.Roles.Count > 0)
Then
Dim role As String
For Each role In node.Roles
If Not String.Equals(role, "*",
StringComparison.InvariantCultureIgnoreCase) Then
Continue For
End If
Return True
Next
End If
Return False
End Function
End Class
End Namespace
<siteMap defaultProvider="CustomSiteMapProvider" enabled="true">
<providers>
<add name="XmlSiteMapProvider"
<add name="CustomSiteMapProvider"
description="This provider overrides the IsAccessibleToUser
method."
type="ASC.Web.CustomSiteMapProvider"
securityTrimmingEnabled="true"
siteMapFile="Web.sitemap" />
</providers>
</siteMap>
"Brock Allen" wrote:
You're going to have to create a custom SiteMapProvider and override
the IsAccessibleToUser method to provide your custom display logic.
The easiest way would be to derive from the existing
XmlSiteMapProvider. Fredrik has some related sample code:

http://fredrik.nsquared2.com/viewpos...howfeedback=tr
ue

-Brock
DevelopMentor
http://staff.develop.com/ballen
I have a master page which contains a Menu control and a SiteMapPath
control, both are bound to the same web.sitemap XML file. Say I have
2 pages, Page 1 and Page 2. Now Page 2 can only be accessed after
selecting some information on Page 1 (using a CrossPagePostback).
When the user get's to Page 2, the SiteMapPath control fails to
render, obviously because Page 2 isn't in the web.sitemap file.

If I put Page 2 in the web.sitemap file, it then get's rendered in
the Menu control, which I don't want. So, is there any way to "hide"
certain nodes in a web.sitemap file from the Menu control?

Or is there anyway I can have the SiteMapPath control render
properly on Page 2 whilst not showing it in the Menu control to the
user?


Nov 19 '05 #5

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

Similar topics

2
by: zapazap | last post by:
Dear Snake Charming Gurus, (Was: http://mail.python.org/pipermail/python-list/2004-January/204454.html) First, a thank you to Tim Golden, Thomas Heller, and Mark Hammond for your earlier help...
6
by: Sandy | last post by:
Hello - I have a book that illustrates pulling menu items from a Sql Server table into an ascx via a stored procedure. Is this something that is done in the real world? I do like the effect...
7
by: Chuck Hartman | last post by:
I have a Windows service that requests web pages from a site using an HttpWebRequest object. When I try to request a page from an ASP.NET 2 site, I get a WebException with message "The remote...
5
by: dpomt | last post by:
When the ASP.NET menu is rendered on downlevel browers, the text "^ up one level" is displayed. Any ideas how I can change that text? I did not find a property for the menu control where I can...
17
by: GS | last post by:
the main menu in the application seemed to disappeared all together until I click on an control and select mainmenu1 in designer. then the mainmenu1 displays where it should be but running it or...
3
by: John | last post by:
Hi there, I was reading an article (http://avenuea-razorfish.com/articles/TheAll-MenuNavigation_Turbek.pdf) on 'all-menu navigation' and I'd like to try and implement this in my site. Can...
5
by: Brad Isaacs | last post by:
Good morning friends, I am working with ASP.NET 2.0 -- VB code behind I have created tabbed pages using the Menu control with the Multiview control. Using the menu control to display the...
2
by: MCM | last post by:
I'm working on a plotting control. The plotting control will have a context menu with basic commands for "scaling", "zooming", etc. Is there a way that, from the parent form, I can add more...
5
by: AG | last post by:
I realize that the obvious suggestion would be malware, but my definitions are up to date and I have already scanned for it. I have also tried disabling all IE add-ons. I just rebuilt and...
4
by: SAL | last post by:
Hello, is there a way to menu control dynamically center itself horizontally on a page? I have placed a menu control in a panel control (no ajax) and would like it to center itself. Depending on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.