I am a newbie in MVC3 Razor world. I get parser error message for following code in a view (cshtml):
@for ( Int32 i = 0 ; i < Model.JobFiles.Count ; i++)
{
<div class="editor-label">
@Html.LabelFor(model => model.JobFiles[i].DisplayName)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.JobFiles[i].DisplayName)
@Html.ValidationMessageFor(model => model.JobFiles[i].DisplayName)
</div>
The parser error message (translated from german to english)
"for" was not expected after the "@" sign. Within the code the construct such as "for" must have no "@".
开发者_开发知识库
But if I remove the "@" I get compiler error, because variable i is not defined.
I need your help and hint for best practice to solve the issue. Thank you in advance.
PS: the code fragment on my first posting was wrong. It is edited now.
I found out the solution by myself: removing the @ from 'for' and put @using System on top of file. Thx to ppl who tried to help me.
精彩评论