How do I apply a CSS class to Html.ActionLink in ASP.NET MVC?

前端 未结 7 717
借酒劲吻你
借酒劲吻你 2020-12-01 06:02

I\'m building an ASP.NET MVC application, using VB.NET and I\'m trying to apply a css class to a Html.ActionLink using the code:



        
7条回答
  •  一个人的身影
    2020-12-01 06:25

    It is:

    <%=Html.ActionLink("Home", "Index", MyRouteValObj, new with {.class = "tab" })%>
    

    In VB.net you set an anonymous type using

    new with {.class = "tab" }
    

    and, as other point out, your third parameter should be an object (could be an anonymous type, also).

提交回复
热议问题