You're pretty close there in terms of syntax. I'm not quite sure what you're trying to achieve but to help get your snippet building you can do the following.
In the razor syntax, you don't need an additional @ sign before the else.
For if, then, else logic, you can't specify another condition after the else unless you say if again, so the final else is a way to say "in every other condition then do this"
As David mentioned your syntax is not correct and you have to change it. Besides that your first if statement is not necessary and you can skip it. See the code below.
@{
var sectionPart = Umbraco.AssignedContentItem.AncestorOrSelf("sectionGeneric");
var pageSectionSubtitle = sectionPart.Children();
}
<ul>
@if(pageSectionSubtitle != null && pageSectionSubtitle.Any())
{
foreach (IPublishedContent page in pageSectionSubtitle)
{
<li>
<h6>@page.Name</h6>
</li>
}
}
</ul>
System.ArgumentNullException
Hello !
I try to handle a null exception with this code block
I don't know why but the else is not a valid term. I'm a student developper so, I think I forget Something. If you've got a clue, that'll be nice.
Thanks
Hi Natalie,
You're pretty close there in terms of syntax. I'm not quite sure what you're trying to achieve but to help get your snippet building you can do the following.
In the razor syntax, you don't need an additional @ sign before the else. For if, then, else logic, you can't specify another condition after the else unless you say if again, so the final else is a way to say "in every other condition then do this"
HTH, David
Hi Natalie,
As David mentioned your syntax is not correct and you have to change it. Besides that your first if statement is not necessary and you can skip it. See the code below.
is working on a reply...