我正在使用Mvc CheckBoxListFor扩展。参数规范似乎对我来说非常正确,因为它在演示中显示但它仍然给我命名参数规范必须在所有固定参数被指定错误后出现。我还想指定id属性。
提前感谢您的帮助。
@Html.CheckBoxListFor(model => model.Categories.PostedCategories.CategoryIds,
model => model.Categories.AvailableCategories,
entity => entity.CategoryId,
entity => entity.Name,
model => model.Categories.SelectedCategories,
position: Position.Horizontal,
x => new { @class = "actcheckbox" }) // here is the line that occurs that error.
@Html.ValidationMessage("catSelectionError")
答案 0 :(得分:0)
正如错误消息所示,您有一个命名参数,后跟一个固定参数 - position: Position.Horizontal
。您似乎需要执行以下操作:
@Html.CheckBoxListFor(model => model.Categories.PostedCategories.CategoryIds,
model => model.Categories.AvailableCategories,
entity => entity.CategoryId,
entity => entity.Name,
model => model.Categories.SelectedCategories,
Position.Horizontal, // NB: No argument name
x => new { @class = "actcheckbox", id = "myid" }) // Add id here