Eyal
Eyal

Reputation: 4763

Adding Class in Html.ActionLink

How can I add here a class name?

 Html.ActionLink(
       item.Name, 
       "GetProducts", 
       "Products", 
        new { CityName = item.CityName.UnderScore(), CategoryName = item.Name.UnderScore() },
        null);

Thanks.

Upvotes: 0

Views: 97

Answers (1)

AliRıza Adıyahşi
AliRıza Adıyahşi

Reputation: 15866

Use this Html.ActionLink overload method

public static MvcHtmlString ActionLink(
    this HtmlHelper htmlHelper,
    string linkText,
    string actionName,
    string controllerName,
    RouteValueDictionary routeValues,
    IDictionary<string, Object> htmlAttributes
)

your example

Html.ActionLink(
   item.Name, 
   "GetProducts", 
   "Products", 
    new { CityName = item.CityName.UnderScore(), CategoryName = item.Name.UnderScore() },
    new { @class="some_class" });

Upvotes: 2

Related Questions