I want a large section of a Razor view to render only if a particular condition is true, but when I put
@if(value) {
at the top of my view, and
@}
at the end of my view, Razor doesn't know what to make of it - I get messages saying the if block is missing a closing "}" character, and that "}" is not valid at the start of a code block. If I change the closing brace line to
@{ } }
that doesn't work either - it interprets the first closing brace as the end of the code block, and doesn't know what the second closing brace is for.
I know that if there were just a couple of html tags in between, I could use @: to make it clear they were HTML lines, but there's a lot more than that in between - there's a long section that's mostly a code block (it starts with @{ and ends with }, and also has some HTML lines in the middle), and also a section that defines a script block and contains a code block, and a block within that... so I'm not sure how to get Razor to recognize that the if that wraps all of that is supposed to function as code.
Many thanks for any assistance!
Aucun commentaire:
Enregistrer un commentaire