我有一个局部视图在剃刀。当我运行它,我得到以下错误 – 似乎像Razor陷入思考我在写代码无处不在。
Unexpected “foreach” keyword after “@” character. Once inside code,you do not need to prefix constructs like “foreach” with “@”
这是我的观点:
@model IEnumerable<SomeModel> <div> @using(Html.BeginForm("Update","UserManagement",FormMethod.Post)) { @Html.Hidden("UserId",ViewBag.UserId) @foreach(var link in Model) { if(link.Linked) { <input type="checkBox" name="userLinks" value="@link.Id" checked="checked" />@link.Description<br /> } else { <input type="checkBox" name="userLinks" value="@link.Id" />@link.Description<br /> } } } </div>