Search code examples
asp.net-mvcasp.net-mvc-4razor-2

@Html.ActionLink not working for css class


Action link @class="info" not working for css

@Html.ActionLink("Click Here", "Details", "Product", new { id = item.ProductId, @class="info" },null)

Html page source

  <a href="/Product/Details/14?class=info">Click Here</a>

Update:

on the other hand

if i set @Html.ActionLink("link here", "Details", "Product", new { id = item.ProductId}) then generate this link localhost:18715/Home/Details?Length=7 why? and it is not working

if i set @Html.ActionLink("link here", "Details", "Product", new { id = item.ProductId},null)

it is working perfectly generate this link http://localhost:18715/Product/Details/17

what i am missing for each link


Solution

  • You have to write hmtl attributes like this:

    @Html.ActionLink("Click Here", "Details", "Product", new { id = item.ProductId }, new { @class = "info"})