I’m having troubles trying the make this code works with razor
@for (int i = 0; i < Model.Count(); i++)
{
<ul>@createSubastaContainer(Model.ElementAt(i))
if (i % 5 == 0)
{
</ul>
}
}
What I want if the element it’s a multiply of 5 print the end of the </ul>
What’s wrong with my code because it’s printing the </ul> all the time and also the expression itself
UPDATE
Base on the red @marteljn answer it when i made the change throws exception
The for 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.
You need to place a
@before yourifstatement, so@if (...but as a side note, this would be a great opportunity to create an extension method that extends the HtmlHelper class.Edit
It is picking up a mismatched tag. The razor view engine enforces HTML compliance when it comes to mismatched tag. So what you can do is replace your tags with
@Html.Raw("<ul>")and@Html.Raw("</ul>").