我正在尝试使用Position.Vertical使我的复选框列表垂直,但不断收到错误消息“当前上下文中不存在名称“ Position”

 @Html.CheckBoxListFor(modelItem => item.Value.postedItems.IDs,
                      modelItem => item.Value.availItems,
                      i => i.Id,
                      i => i.Name,
                      modelItem => item.Value.selectedItems,
                      Position.Vertical)


如果我转到Html.checkboxlist的定义,则存在参数Position的替代,但是由于某些原因,未使用它。

public static MvcHtmlString CheckBoxListFor<TModel, TProperty, TItem, TValue, TKey>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> listNameExpr, Expression<Func<TModel, IEnumerable<TItem>>> sourceDataExpr, Expression<Func<TItem, TValue>> valueExpr, Expression<Func<TItem, TKey>> textToDisplayExpr, Expression<Func<TModel, IEnumerable<TItem>>> selectedValuesExpr, HtmlListInfo wrapInfo);



public static MvcHtmlString CheckBoxListFor<TModel, TProperty, TItem, TValue, TKey>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> listNameExpr, Expression<Func<TModel, IEnumerable<TItem>>> sourceDataExpr, Expression<Func<TItem, TValue>> valueExpr, Expression<Func<TItem, TKey>> textToDisplayExpr, Expression<Func<TModel, IEnumerable<TItem>>> selectedValuesExpr, Position position);


使用第一个替代而不是第二个。是否有某种方法可以强制使用第二种情况?

最佳答案

我认为您的问题是您没有声明正确的“使用”引用。
尝试将@using MvcCheckBoxList.Model添加到视图中。

10-04 22:24
查看更多