gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 20:51:28 26 4
gpt4 key购买 nike

我正在尝试使用 Steve Sanderson's blog post关于编辑可变长度列表。我已经通过 NuGet 包管理器安装了 dll,并确保命名空间位于 Views/web.config 文件中。但是,当我尝试编写 using 语句时出现以下错误。

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>

局部 View (更新)

@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 (以防万一)

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

关于c# - System.Web.Mvc.HtmlHelper<ModelName> 不包含定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23436360/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com