如何修复调用自定义actionlink方法

时间:2012-06-26 07:27:27

标签: c# asp.net asp.net-mvc-3

我创建了这个自定义动作链接

public static IHtmlString CustomActionLink(this HtmlHelper htmlHelper, int userId, string controller, string linkText, string action)
    {
        int userID = userId;
        bool isAllowed = checkPermission(userID,action,controller);
        if (isAllowed == false)
        {
            return MvcHtmlString.Empty;
        }
        return htmlHelper.ActionLink(linkText, action);
    }

我尝试将此方法称为 Helper.CustomActionLink(4"&myController的#34;"文本"" MyAction&#34) 但是它要求我传递第一个论点'这个HtmlHelper htmlHelper'我如何解决这个问题

1 个答案:

答案 0 :(得分:2)

您应该这样称呼它:

@Html.CustomActionLink(4,"myController","text","MyAction")