I have the following MVC 4 Razor code:
@for (int i = 1; i <= 100; i++) {
if (currentCol == 1) {
Html.Raw("<div class=row>");
@*Need to do this because can't have a open div within a if compiler doesnt like it *@
} if (currentCol == maxCol) {
Html.Raw("</div>");
}
currentCol++;
}
I am basically trying to generate the contents of every div class row conditionally with the start and end tags in different paths of the if statements. When I just use straight HTML, the compiler doesn't like it and thinks the brackets are off. It seems like Html.Raw
is the solution from my searches online, but when I use Html.Raw
, the div doesn't show up when I view the source.
Does anyone know what's going on?