I got a trivial issue.. and can't solve it.
I have this in my view:
<% if (!Model.DisplayText) { %> <%= Model.MyText %> <% } %>
As you can see, i am using 3x <% and %>. That just screams like bad code. But I can't seem to get this working in a single line. This throws all kinds of weird errors (such as semicolon missing, and when I add one it throws something else):
<% if (!Model.DisplayText) { Model.MyText } %>
Any idea?!
This:
is generally equivalent to:
So you can write:
but I don't see what you really get from this. Your original code is fine as it is. Or you might use the ternary operator, as OrbMan suggests.
Or go with OrbMan's answer, he beat me to it.
Try:
or