1
Vote

Html.DetailLink is calling incorrect Ajax.ActionLink Method

description

In MVCControlsToolkit.Controls.DataFormHelpers.cs there is a method:
public static MvcHtmlString DetailLink<TItem>(
            this HtmlHelper<TItem> htmlHelper,
            AjaxHelper ajax,
            string text,
            DetailType detailType,
            string controllerAction,
            string controllerName,
            object parameters,
            string loadingElementId,
            IDictionary<string, object> htmlAttributes = null,
            string beforeStart=null)
At the end this method creates a new Ajax.ActionLink, but if you pass in some htmlAttributes these do not get applied to the ActionLink. This is because the datatype for parameters is incorrect.

So DetailLink is now calling:
public static MvcHtmlString ActionLink(
    this AjaxHelper ajaxHelper,
    string linkText,
    string actionName,
    object routeValues,
    AjaxOptions ajaxOptions,
    object htmlAttributes
)
instead of:
public static MvcHtmlString ActionLink(
    this AjaxHelper ajaxHelper,
    string linkText,
    string actionName,
    RouteValueDictionary routeValues,
    AjaxOptions ajaxOptions,
    IDictionary<string, object> htmlAttributes
)
The casting from IDictionary<string, object> htmlAttribute to object htmlAttributes fails and does not return the correct MvcHtmlString.

Need to change object parameters to RouteValueDictionary parameters

Here is a reference to how I spotted the problem.
Reference 1

comments