Mvc CheckBoxListFor 命名参数规范错误
Mvc CheckBoxListFor named argument specifications error
我正在使用 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")
如错误消息所示,您有一个命名参数,后跟一个固定参数 - 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
我正在使用 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")
如错误消息所示,您有一个命名参数,后跟一个固定参数 - 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