System.Web.Mvc.HtmlHelper<&MODELNAME GT;不包含一个定义 [英] System.Web.Mvc.HtmlHelper<ModelName> does not contain a definition for

查看:361
本文介绍了System.Web.Mvc.HtmlHelper<&MODELNAME GT;不包含一个定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用的史蒂夫·桑德森的博客文章有关编辑可变长度的名单。我已经安装了通过的NuGet包管理器的DLL,并确保该命名空间是在查看/ web.config中文件。不过,我下面的错误,当我试图写的使用说明书。

  System.Web.Mvc.HtmlHelper< Monet.Models.AgentTransmission>不包含一个定义
对于BeginCollectionItem',没有扩展方法'BeginCollectionItem接受第一
类型的参数'System.Web.Mvc.HtmlHelper< Monet.Models.AgentTransmission>'可能
(是否缺少using指令或assmebly参考

查看/ Web.config中

 <&命名空间GT;
      <添加命名空间=System.Web.Mvc/>
      <添加命名空间=System.Web.Mvc.Ajax/>
      <添加命名空间=System.Web.Mvc.Html/>
      <添加命名空间=System.Web.Routing/>
      <添加命名空间=HtmlHelpers.BeginCollectionItem/>
    < /命名空间>

局部视图(更新)

  @model Monet.Models.AgentRelationship codeS@using(Html.BeginCollectionItem(AgentRelationship codeS))
{
    &所述; TR>
        < TD> @ Html.EditorFor(型号=> model.EffectiveDate,NullableDate,新{@class =相对codeDate2})LT; / TD>
        < TD> @ Html.EditorFor(型号=> model.RelationshipId,NullableDate,新{@class =relDist code1,最大长度= 3})LT; / TD>
        @ Html.HiddenFor(型号=> model.ID)
        @ Html.HiddenFor(型号=> model.Rel codeOrdinal)
    < / TR>
}

控制器(以防万一)

 使用系统;
使用System.Collections.Generic;
使用System.Configuration;
使用System.Data这;
使用System.Data.Entity.Validation;
使用System.Diagnostics程序;
使用System.IO;
使用System.Linq的;
使用System.Net;
使用的System.Reflection;
使用System.Runtime.Serialization;
使用System.Text;
使用System.Transactions的;
使用的System.Web;
使用System.Web.Mvc;
使用System.Web.Routing;
使用的System.Xml;
使用Monet.MonetToDss;
使用Monet.Common;
使用Monet.Models;
使用Monet.ViewModel;
使用HtmlHelpers.BeginCollectionItem;公众的ViewResult NewRelationship code()
{
    返回视图(AddRelationship codePartial,新AgentRelationship codeS());
}


解决方案

请尝试关闭并重新打开了由编辑器拿起变化的解决方案。这样做,我没有得到错误后


  

System.Web.Mvc.HtmlHelper不
  包含BeginCollectionItem'没有扩展名的定义
  方法BeginCollectionItem接受式的第一个参数
  System.Web.Mvc.HtmlHelper可能是
  (是否缺少using指令或assmebly参考


I am trying to use Steve Sanderson's blog post about editing a variable length list. I've installed the dll via the NuGet package manager and made sure that the namespace is in the Views/web.config file. However, I the following error when I attempt to write the using statment.

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

Views/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>

Partial View (updated)

@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, "NullableDate", new { @class = "relDistCode1", maxlength = 3 })</td>
        @Html.HiddenFor(model => model.ID)
        @Html.HiddenFor(model => model.RelCodeOrdinal)
    </tr>
}

Controller (just in case)

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());
}

解决方案

Please try to close and re-open the solution for the changes to be picked up by editor. After doing that I don't get the error

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

这篇关于System.Web.Mvc.HtmlHelper&LT;&MODELNAME GT;不包含一个定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆