我正在尝试构建一个AjaxHelper扩展,并且似乎遇到了SNAFU。MVC AjaxHelper扩展 - 系统找不到它?
查看:
<%= Ajax.DeleteLink("Delete", "LicenseDelete", "Directory", new { LicenseID = license.ID }, new { @class = "directory button" }); %>
扩展:
using System;
using System.Collections.Generic;
using System.Web.Mvc;
using System.Linq.Expressions;
using System.Web.Routing;
using System.Web.Mvc.Ajax;
namespace RainWorx.FrameWorx.MVC
{
public static class HtmlExtensions
{
public static MvcHtmlString DeleteLink<TModel>(this AjaxHelper<TModel> ajaxHelper, string linkText, string actionName, string controllerName, object routeValues, object htmlAttributes)
{
return ajaxHelper.ActionLink(linkText
, actionName
, controllerName
, routeValues
, new AjaxOptions { Confirm = "Are you sure you want to delete this item?",
HttpMethod = "DELETE",
OnSuccess = "function() { window.location.reload(); }" }
, htmlAttributes);
}
}
}
浏览器的结果:在 '/' 应用
服务器错误。
编译错误
描述:编译服务此请求所需的资源 时发生错误。请仔细阅读以下具体的 错误详细信息并适当修改您的源代码。编译器错误消息:CS1061: 'System.Web.Mvc.AjaxHelper < RainWorx.FrameWorx.MVC.ViewModels.DirectoryEdit>' 不包含关于 'DeleteLink' 的定义和没有扩展方法 'DeleteLink' 接受类型的第一个参数 “System.Web.Mvc.AjaxHelper < RainWorx.FrameWorx.MVC.ViewModels.DirectoryEdit>” 可以找到(是否缺少使用指令或程序集 引用?)
我错过了什么(明显的)事情?我可以在我的扩展方法中发誓第一个参数确实几乎接受我选择抛弃它的任何模型。
TIA
-kb
难道他们都在同一个命名空间? –