Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I'm working on a macro in razor and keep running into a strange issue:
@{var startNode = @Model.AncestorOrSelf().Regions.First();}<ul> <li> <a href="@startNode.Url">Home</a> </li> @{ int index = 0; } foreach (var contentItem in @startNode.ContentPages) { <li @(startNode.ContentPages.Count() - 1 == index ? "style=border-right:none;":null)> <a href="@contentItem.Url">@contentItem.Name</a> </li> index++; }</ul>
This code returns this error:
Navigation.cshtml(13): error CS0103: The name 'contentItem' does not exist in the current context
Any ideas?
Hi. Try to add a '@' sign right before 'foreach'.
Works great, thanks! I can't believe I didn't see that.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Error CS0103 in Razor Script
I'm working on a macro in razor and keep running into a strange issue:
This code returns this error:
Navigation.cshtml(13): error CS0103: The name 'contentItem' does not exist in the current context
Any ideas?
Hi. Try to add a '@' sign right before 'foreach'.
Works great, thanks! I can't believe I didn't see that.
is working on a reply...