It helps me to think of "modes" - when you write a @{ or begin a code bloc @foreach you're in razor code "mode" until you throw a line of HTML in which switches the mode to HTML.
I sometimes use the @: marker to output a "quick" line of HTML whilst still retaining the Razor code mode. So you can do things like:
@foreach(var page in startNode.Children.Where("Visible")){
Why do "elements" have to contain html?
I have an issue, that keeps coming back in every project i work on, and now i really need to know to to solve it for good.
For some reason whenever i have a razor context, it has to have html inside, or else it fails. Example:
Works fine, but it's not really what i want. I want the intire link and image inside the if
But this fails... Why?
And how do i get it right. I often run into similar cases where stuff fails due to empty "elements".
I think i figured it out... You cant have a @ inside some other @.
So it needs to be
Could someone point to a thorough explantion to how these @ indicators work?
Hi
I believe if you just remove the @ sign before if , it should sort it out
Cheers
Ali
It helps me to think of "modes" - when you write a @{ or begin a code bloc @foreach you're in razor code "mode" until you throw a line of HTML in which switches the mode to HTML.
I sometimes use the @: marker to output a "quick" line of HTML whilst still retaining the Razor code mode. So you can do things like:
@: <h1>Perhaps some debug output @page.Id</h1>
is working on a reply...