I get this error, which totally blows me off: error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement
Ooh d'oh! of course, I didn't think of that. You could try that or just @node.Title and @node.Name (by the way, no need to type nodeName, just Name is fine).
FYI: it depends if there's html before and after the @if. The context switching is a bit hard to figure out at first. :-)
What is wrong with this if/else ?
I'm trying my first Razor stuff and I'm producing questions like rabbits are producing offspring :)
What's wrong with this:
I get this error, which totally blows me off: error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement
It sounds like something from Redmond :)
The title has probably never been filled in, so it might be null instead of having no lengths, try this:
Hmmm ... I've tried that but without any luck.
I also changed node.nodeName to node.Name
Still getting the same error
Hi Sebastia(a)n :-)
I believe I read somewhere that you need to use aelement around standalone expressions like those (where you're not wrapping them in a or similar)
So:
/Chriztian
Ooh d'oh! of course, I didn't think of that. You could try that or just @node.Title and @node.Name (by the way, no need to type nodeName, just Name is fine).
FYI: it depends if there's html before and after the @if. The context switching is a bit hard to figure out at first. :-)
If "node" is of type DynamicNode, e.g.:
Than next script should work
@if (!node.IsNull("title") && node.HasValue("title")) {
@node.Title;
} else {
@node.Name;
}
is working on a reply...