 |
| ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

April 10th, 2011, 08:44 AM
|
|
Authorized User
|
|
Join Date: Jan 2011
Posts: 89
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
Different items in WebSiteMap and Menu
Am I right in saying you can only have one Web.sitemap? I have an issue where I have all pages for the WebSiteMap but dont want them all included in the menu, whats the best way to dis-include some items from the menu?
|
|

April 10th, 2011, 08:48 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Quote:
|
Am I right in saying you can only have one Web.sitemap?
|
Nope, you can have multiple site maps but you need to register them:
http://msdn.microsoft.com/en-us/library/ms178426.aspx
Cheers,
Imar
|
|

April 10th, 2011, 04:35 PM
|
|
Authorized User
|
|
Join Date: Jan 2011
Posts: 89
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
I created two sitemap files: SiteMapPath.sitemap and Menu.sitemap, I added them as described in web.config:
<siteMap defaultProvider="SiteMapPath">
<providers>
<add name="SiteMapPath" type="System.Web.XmlSiteMapProvider" siteMapFile="~/SiteMapPath.sitemap"/>
<add name="Menu" type="System.Web.XmlSiteMapProvider" siteMapFile="~/Menu.sitemap"/>
</providers>
</siteMap>
- and set SiteMapProvider="SiteMapPath" for the SiteMapPath control which is fine but there is no SiteMapProvider attribute for the Menu control so I'm unable to assing the menu to its own site map file??
|
|

April 11th, 2011, 03:01 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi Alex,
A Menu has a DataSourceID property which can refer to a SiteMapDataSoource control in your page. The SiteMapDataSource control (from the Data category of the Toolbox) then has a SiteMapProvider property.
Hope this helps,
Imar
|
|

April 11th, 2011, 06:23 AM
|
|
Authorized User
|
|
Join Date: Jan 2011
Posts: 89
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
Hi Imar,
For the menu I set DataSourceID="MenuSiteMapDataSource", which is the ID of the SiteMapDataSource control which in turn has SiteMapProvider="MenuSiteMap".
In Web.config I have:
<siteMap defaultProvider="MenuSiteMap">
<providers>
<add name="MenuSiteMap" type="System.Web.SiteMapProvider" siteMapFile="~/Menu.sitemap" />
<add name="SMPSiteMap" type="System.Web.SiteMapProvider" siteMapFile="~/SiteMapPath.sitemap" />
</providers>
</siteMap>
- but I keep getting errors saying: Cannot create an abstract class - against the type attribute??
|
|

April 11th, 2011, 07:56 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi Alex,
System.Web.SiteMapProvider is indeed an abstract class. So, you need to register one of its concrete descendents instead. In an earlier post you used the System.Web.XmlSiteMapProvider which is the correct type.
Cheers,
Imar
|
|

April 11th, 2011, 12:26 PM
|
|
Authorized User
|
|
Join Date: Jan 2011
Posts: 89
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
Thanks for the help again Imar, I couldnt find where to explicitly set the SiteMapPath's SiteMapDataSource control (like with DataSourceID in the menu) so I set this one as the defaultProvider so it picked it up.
|
|
 |