Asp.net mvc 3 自定义MVC3帮助程序的语法错误

Asp.net mvc 3 自定义MVC3帮助程序的语法错误,asp.net-mvc-3,Asp.net Mvc 3,我正在尝试构建一个自定义HTML帮助程序。在几个教程之后,我的代码是- namespace System.Web.Mvc.Html { using System; using System.Web.Mvc; public static class HtmlHelpers { public static string BuildJsonPrototype(this HtmlHelper helper, string targetName)

我正在尝试构建一个自定义HTML帮助程序。在几个教程之后,我的代码是-

namespace System.Web.Mvc.Html 
{
    using System;
    using System.Web.Mvc;
    public static class HtmlHelpers
    {
        public static string BuildJsonPrototype(this HtmlHelper helper, string targetName)
        {
            var d = BuildJsonModel.Build( typeof(Int32), targetName);
            return d;
        }
    }
}
@using System.Web.Mvc.Html    
@Html.BuildJsonModel( "test")
在我看来,代码是-

namespace System.Web.Mvc.Html 
{
    using System;
    using System.Web.Mvc;
    public static class HtmlHelpers
    {
        public static string BuildJsonPrototype(this HtmlHelper helper, string targetName)
        {
            var d = BuildJsonModel.Build( typeof(Int32), targetName);
            return d;
        }
    }
}
@using System.Web.Mvc.Html    
@Html.BuildJsonModel( "test")
当我试着运行它时,我得到了以下编译器错误-

Compiler Error Message: CS1061: 'System.Web.Mvc.HtmlHelper<AutoBind.Models.ComplexModel>'
does not contain a definition for 'BuildJsonModel' and no extension method
'BuildJsonModel' accepting a first argument of type
'System.Web.Mvc.HtmlHelper <AutoBind.Models.ComplexModel>' could be found
(are you missing a using directive or an assembly reference?)
编译器错误消息:CS1061:'System.Web.Mvc.HtmlHelper'
不包含“BuildJsonModel”的定义,也不包含扩展方法
“BuildJsonModel”接受类型为的第一个参数
可以找到“System.Web.Mvc.HtmlHelper”
(是否缺少using指令或程序集引用?)

关于我的语法错误是什么有什么建议吗?

您的代码建议将助手称为“BuildJsonPrototype”,但在您的标记中使用的是“BuildJsonModel”?这就是问题所在吗?

显而易见的事情总是你看不见的。谢谢。没问题——我们都去过那里太多次了:)