2012-06-26 18 views
0

我創建這個定製的ActionLink如何解決,呼籲定製ActionLink的方法

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的」, 「文本」, 「MyAction」) 但它讓我轉達的第一個參數也「這的HtmlHelper的HtmlHelper」我該如何解決這個問題

回答

2

你應該稱呼它:

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

由於它的工作原理 –