asp.net mvc 3 - Outputting literal HTML between razor statements results in compilation error -
i have foo object, , want output:
title, location
so try...:
@if (sometruestuff){ @foo.title, @foo.location } @if (sometruestuff){ @foo.title , @foo.location }
both fail compile.
however...:
@if (sometruestuff){ @foo.title<span>,</span> @foo.location }
...works.
is there trick missing?
edit: happens inside codeblock, updated reflect this.
you escape ,
using @:
because razor parser considers part of server side code , if want output comma in html needs escaped:
@if (sometruestuff){ @foo.title@:, @foo.location }
Comments
Post a Comment