c# - Is there a way to terminate MVC Razor @: line? -
consider example:
<input type="checkbox" @if (flag) { @: checked } />
the problem } />
conceived razor engine part of output string.
i've tried use parenthesis no luck.
is there way terminate @:
operator in same line, or i'll have split other line / use ternary operator?
update
a common use-case of request can adding class if value true:
<div class='container @(active ? "active")'/>
so if :
of ternary operator isn't present, treats treats unary if
operator, that's wish...
here's suggestion on c# uservoice.
for single attribute can use @value
syntax, have special case checkbox (see razor quick reference ):
<input type="checkbox" checked="@flag" />
you can use <text>
syntax provides explicit (instead of "up end of line") closing tag:
<input type="checkbox" @if (flag) { <text>checked</text> } />
Comments
Post a Comment