I'm trying to write a simple foreach loop with c# razor and am getting stuck. I feel sure I've done something obviously wrong.
I am attemping to loop through all nodes with a certain doc type of "Product" (located in different folders in my content tree) and list out their node names.
This is what I have so far:
var products = Model.NodeTypeAlias("Product").Visible;
<ul>
@foreach(var product in products)
{
<li>product.Name</li>
}
</ul>
But I'm getting "Error loading Macro" on screen.
Seems like it should be simple but I can't work it out.
Problem with simple foreach loop in Razor
I'm trying to write a simple foreach loop with c# razor and am getting stuck. I feel sure I've done something obviously wrong.
I am attemping to loop through all nodes with a certain doc type of "Product" (located in different folders in my content tree) and list out their node names.
This is what I have so far:
But I'm getting "Error loading Macro" on screen.
Seems like it should be simple but I can't work it out.
Thank you.
Hi John
Try this instead
Perfect, thank you. I really need to learn Razor properly :(
is working on a reply...