Click here to Skip to main content
15,891,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want nodes like this way ,

1) Dashboard
2) Account
2a) Register
2b) Log off
2c) Test1
2d) Test2

so i wrote below code , in Mvc.sitemap
XML
<?xml version="1.0" encoding="utf-8" ?>
<mvcSiteMap xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-4.0"
            xsi:schemaLocation="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-4.0 MvcSiteMapSchema.xsd">

    <mvcSiteMapNode title="Dashboard" controller="Home" action="Index" description="fa fa-home" />
    <mvcSiteMapNode title="Account" controller="Account" action="Index" roles="admin" description="fa fa-envelope">
      <mvcSiteMapNode title="Register" controller="Account" action="Register" />
      <mvcSiteMapNode title="Log off" controller="Account" action="LogOff" />
      <mvcSiteMapNode title="Test1" controller="Account" action="LogOff" />
      <mvcSiteMapNode title="Test2" controller="Account" action="LogOff" />
    </mvcSiteMapNode>
</mvcSiteMap>


and in SiteMapPathHelperModel.cshtml

HTML
<ul>
    @foreach (var node in Model)
    {   
        @Html.DisplayFor(m => node)
        var iconClass = node.Description.ToString();


        if (node.Children.Any())
        {

        < i class="@iconClass" aria-hidden="true"></ i> /* this is to show icon */
 @Html.DisplayFor(m => node.Children)
        }
    }

</ul>


but its not allow write 2 sitemapnodes .
Can any one tell me how to this.
Thank you.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900