Menu ans submenu error

Nov 4, 2010 at 6:11 PM

Hello, I'm new in MVC and I'm doing my fist app using MVC2.  I download and used de mvcsitemap provider to build the sitemap of my project, but I have this problem, I cant see all the nodes in my sitemap when I create my menu.

My file .sitemap is this:

<?xml version="1.0" encoding="utf-8" ?>
<mvcSiteMap xmlns="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-2.0" enableLocalization="true">
<mvcSiteMapNode title="Home" controller="Home" action="Index" isDynamic="true" dynamicParameters="*" roles="*">
 <mvcSiteMapNode title="About Us" controller="Home" action="About"  roles="*">
  <mvcSiteMapNode title="New Client" controller="xxparamclient" action="Create" roles="*"/>
 </mvcSiteMapNode>
 <mvcSiteMapNode title="Cliente" controller="xxparamclient" action="Index"  roles="*"/>
  </mvcSiteMapNode>
<mvcSiteMapNode title="Cliente" controller="xxparamclient" action="Index" roles="*">
  <mvcSiteMapNode title="List Client" controller="xxparamclient" action="Index" roles="*"/>
  <mvcSiteMapNode title="New Client" controller="xxparamclient" action="Create" roles="*"/>
 </mvcSiteMapNode>
</mvcSiteMap>

 

As you can see I have 3 levels on my sitemap.  When in my Site.Master, I call the menu:

<%= Html.MvcSiteMap().Menu()%>

and then build my project, the menu is not complete, it's only shows this:

  • Home
  • About us
  • Cliente

 I need to show this:

  • Home
    • About Us
      • Cliente
  • Cliente
    • List Client
    • New Client

I'm using mvcsitemapprovider 2.2.1 and I' didnt found information about the submenu htmlhelper, and either about the max level that the menu is going to show.

How can I do that?

Coordinator
Nov 4, 2010 at 8:27 PM

The problem is that xxparamclientController / Index are defined 2 times. MvcSiteMap will have an impossible task on figuring out how that happens. The solution is having one node == one action.

Try rewriting your sitemap like:

<?xml version="1.0" encoding="utf-8" ?>
<mvcSiteMap xmlns="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-2.0" enableLocalization="true">
<mvcSiteMapNode title="Home" controller="Home" action="Index" isDynamic="true" dynamicParameters="*" roles="*">
 <mvcSiteMapNode title="About Us" controller="Home" action="About"  roles="*">
  <mvcSiteMapNode title="New Client" controller="xxparamclient" action="Create" roles="*"/>
 </mvcSiteMapNode>
  </mvcSiteMapNode>
<mvcSiteMapNode title="Cliente" controller="xxparamclient" action="Index" roles="*">
  <mvcSiteMapNode title="List Client" controller="xxparamclient" action="Index" roles="*"/>
  <mvcSiteMapNode title="New Client" controller="xxparamclient" action="Create" roles="*"/>
 </mvcSiteMapNode>
</mvcSiteMap>