I am trying to build a AjaxHelper extension and seem to be running into a SNAFU.
View:
<%= Ajax.DeleteLink("Delete", "LicenseDelete", "Directory", new { LicenseID = license.ID }, new { @class = "directory button" }); %>
Extension:
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);
}
}
}
Browser result:
Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.Compiler Error Message: CS1061: 'System.Web.Mvc.AjaxHelper<RainWorx.FrameWorx.MVC.ViewModels.DirectoryEdit>' does not contain a definition for 'DeleteLink' and no extension method 'DeleteLink' accepting a first argument of type 'System.Web.Mvc.AjaxHelper<RainWorx.FrameWorx.MVC.ViewModels.DirectoryEdit>' could be found (are you missing a using directive or an assembly reference?)
What (obvious) thing did I miss? I can swear the first argument in my extension method does accept pretty much any model I choose to throw at it.
TIA
-kb