Html.ActionLink with a specified HTML id?

前端 未结 4 857
青春惊慌失措
青春惊慌失措 2021-02-02 06:47

I\'d like to give the like generated with an Html.ActionLink an HTML id so I can change the CSS depending on where I am. I have a MasterPage with a set

4条回答
  •  囚心锁ツ
    2021-02-02 07:40

    Basically it's giving an error because there is no method overload that has the signature you want.

    The closest signature to the one that you need is

    public static string ActionLink(
    this HtmlHelper htmlHelper,
    string linkText,
    string actionName,
    string controllerName,
    Object routeValues,
    Object htmlAttributes
    

    )

    You are passing the id attribute into the routevalue which is why it's giving you the funny href. pass null into the routevalue, then add your htmlattributes

提交回复
热议问题