There are many complex HTML reports in my current project where we do a lot of conditional rendering of TR and TD using rows and colspans.
Sometimes it may look (this is very simplified):
<tr> @foreach (var ourItem in ourList) { if (ourItem != ourList.First()) { <tr> } <td></td> </tr> }
However, Razor states: "There is no closing"} "character in the foreach loop." (in Visual Studio)
I tried to wrap <tr> in <text></text> , which is why the closing problem closes, only to find it at startup: "Encounted end tag" tr "without the corresponding start tag. Tags are properly balanced."
How would I do such a conditional rendering, convincing Razor not to worry about HTML at all, because HTML is balanced when all the loops are complete. Or at least that was the case when using the ASP.NET View Engine.
asp.net-mvc asp.net-mvc-3 razor
Mikael Östberg Jan 24 '11 at 12:22 2011-01-24 12:22
source share