Question

I'm trying to do something I thought was obvious, but I can't find a doc on this to save my life.. Basically, I want to build a list of links for all children of a page by it's name.. I'm trying this with no luck.. Is there an easy way to accomplish this?

@foreach (var page in Model.Content.Where(page => page.Name.Equals("About")).Children) { 
   <a href="">...</a>
}
Was it helpful?

Solution

If you mean you want links to the current page's children who are named "About" then you can do:

@foreach(var page in @Model.Content.Children.Where(x => x.Name == "About"))
{
    <a href="@page.Url">@page.Name</a>
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top