我正在使用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")发布于 2016-05-24 17:17:13
正如错误消息所示,您有一个命名的参数,后面跟着一个固定的参数-- 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 herehttps://stackoverflow.com/questions/37419777
复制相似问题