umbraco 8 nested content programmatically code example

Example 1: umbraco nested content

//Umbraco 8+
@{
    var items = Model.Value<IEnumerable<IPublishedElement>>("myPropertyAlias");

    foreach(var item in items)
    {
        // Render your content, e.g. item.Value<string>("heading")
    }
}

Example 2: umbraco nested content

//Umbraco 7
@{
    var items = Model.GetPropertyValue<IEnumerable<IPublishedContent>>("myPropertyAlias");

    foreach(var item in items)
    {
        // Render your content, e.g. item.GetPropertyValue<string>("heading")
    }
}

Tags:

Misc Example