Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mvc3 razor conditional wrapper div

What's the best way to handle something like this:

Razor Code:

@if(!disableRowDiv) {     <div class="row"> }  <div>some content here</div>  @if(!disableRowDiv) {     </div> } 

So that the Razor engine doesn't produce this error :

Parser Error Message:

The if block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup.

like image 748
Rob Avatar asked Aug 15 '12 12:08

Rob


1 Answers

This should work

@if(!disableRowDiv) {     @:<div class="row"> } <div>some content here</div> @if(!disableRowDiv) {     @:</div> } 
like image 137
Shyju Avatar answered Nov 12 '22 16:11

Shyju