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

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -