} @if(item.i % 2 == 0) { } Witho...">

Razor and half-processing html tags

How to do it?

@if(item.i % 2 == 0)
{
   <div class="row">
}       

@if(item.i % 2 == 0)
{
   </div>
}

      

Without complaining that I hadn't finished the tag and thus thought I hadn't put }

at the end of the if statement

+3


source to share


2 answers


You need to attach both lines with @:

so that the Razor parser doesn't parse the HTML tags.



@if(item.i % 2 == 0)
{
   @:<div class="row">
}       

@if(item.i % 2 == 0)
{
   @:</div>
}

      

+6


source


What would I do id this

@(item.i % 2 == 0 ? "<div class='row'>" : "</div>")

      



I think it will work;)

Hf!

0


source







All Articles