c# – System.Web.Mvc.HtmlHelper不包含的定义

我正在尝试使用 Steve Sanderson’s blog post关于编辑可变长度列表.我已经通过NuGet包管理器安装了dll,并确保命名空间位于Views / web.config文件中.但是,当我尝试编写使用语句时,我出现以下错误.
System.Web.Mvc.HtmlHelper<Monet.Models.AgentTransmission> does not contain a definition 
for 'BeginCollectionItem' and no extension method 'BeginCollectionItem' accepting a first 
argument of type 'System.Web.Mvc.HtmlHelper<Monet.Models.AgentTransmission>' could be 
found (are you missing a using directive or an assmebly reference

查看/ Web.config中

<namespaces>
      <add namespace="System.Web.Mvc" />
      <add namespace="System.Web.Mvc.Ajax" />
      <add namespace="System.Web.Mvc.Html" />
      <add namespace="System.Web.Routing" />
      <add namespace="HtmlHelpers.BeginCollectionItem" />
    </namespaces>

部分视图(更新)

@model Monet.Models.AgentRelationshipCodes

@using (Html.BeginCollectionItem("AgentRelationshipCodes"))
{
    <tr>
        <td>@Html.EditorFor(model => model.EffectiveDate,"NullableDate",new { @class = "relCodeDate2" })</td>
        <td>@Html.EditorFor(model => model.RelationshipId,new { @class = "relDistCode1",maxlength = 3 })</td>
        @Html.HiddenFor(model => model.ID)
        @Html.HiddenFor(model => model.RelCodeOrdinal)
    </tr>
}

控制器(以防万一)

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.Entity.Validation;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Runtime.Serialization;
using System.Text;
using System.Transactions;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using System.Xml;
using Monet.MonetToDss;
using Monet.Common;
using Monet.Models;
using Monet.ViewModel;
using HtmlHelpers.BeginCollectionItem;

public ViewResult NewRelationshipCode()
{
    return View("AddRelationshipCodePartial",new AgentRelationshipCodes());
}

解决方法

请尝试关闭并重新打开解决方案,以便编辑器选择更改.在这之后我没有得到错误

System.Web.Mvc.HtmlHelper does not contain a definition for ‘BeginCollectionItem’ and no extension method ‘BeginCollectionItem’ accepting a first argument of type ‘System.Web.Mvc.HtmlHelper’ could be found (are you missing a using directive or an assmebly reference

相关文章

项目中经常遇到CSV文件的读写需求,其中的难点主要是CSV文件...
简介 本文的初衷是希望帮助那些有其它平台视觉算法开发经验的...
这篇文章主要简单记录一下C#项目的dll文件管理方法,以便后期...
在C#中的使用JSON序列化及反序列化时,推荐使用Json.NET——...
事件总线是对发布-订阅模式的一种实现,是一种集中式事件处理...
通用翻译API的HTTPS 地址为https://fanyi-api.baidu.com/api...