html - The closing braces of my C# code are not recognized in a Razor partial view -
i working on asp.net mvc 3 application. use razor views. had problem friday , thought have fixed see private case things worked reason.
i have table 4 columns, each row may have different number of fields in 1 cell i'm working on sort of algorithm fill cells info belong them. have :
@{ int tempcolumn = 1; } <tr> @foreach (var field in model) { if (field != null) { <td> @for (int = 0; < field.count; i++) { if (field[i].columnno == tempcolumn) { @field[i].questiontext; @field[i].fieldvalue; } else if (field[i] != null) { tempcolumn++; @:</td> @:<td> @field[i].questiontext; @field[i].fieldvalue; } } } @:</td> } </tr>
basically idea no matter how many pairs of @field[i].questiontext;
/ @field[i].fieldvalue;
have have opening <td>
tag @ begining of row , closing </td>
tag @ end of row. have problems algorithm before fix issue not recognized closing bracelets can't continue. error - when try , run code in debug mode error :
the foreach block missing closing "}" character. make sure have matching "}" character "{" characters within block, , none of "}" characters being interpreted markup.
but when go code same error if
block , for
block. thought inserting html <td>
, </td>
tags using syntax - @:
keep sructure of c# code , add tags want them, think seems reason @ least 1 <td>
or </td>
tag interpreted after recognized html markup , not c# code. proper way insert html markup in c# method, or if error cause else - be?
p.s
any algorithm appreciated though it's not topic of question.
change
} } } @:</td> } </tr>
to
} } </td> } } </tr>
you start <td>
inside if (field != null)
should end in inside there well, otherwise if field == null
you'll <tr></td></tr>
.
Comments
Post a Comment