ActionLink htmlAttributes with hyphens

The problem is that your anonymous object property data-icon has an invalid name. C# properties cannot have dashes in their names. There are two ways you can get around that: Use an underscore instead of dash (MVC will automatically replace the underscore with a dash in the emitted HTML): @Html.ActionLink(“Edit”, “edit”, “markets”, new { id … Read more

ASP.NET MVC – Pass array object as a route value within Html.ActionLink(…)

Try creating a RouteValueDictionary holding your values. You’ll have to give each entry a different key. <% var rv = new RouteValueDictionary(); var strings = GetStringArray(); for (int i = 0; i < strings.Length; ++i) { rv[“str[” + i + “]”] = strings[i]; } %> <%= Html.ActionLink( “Link”, “Action”, “Controller”, rv, null ) %> will … Read more

Html.ActionLink with a specified HTML id?

You were on the right track. I am not sure why it didn’t work for you as your code has a typo which would have produced a } expected error. The following is what you are looking for: <%= Html.ActionLink(“Test Link”, “SomeAction”, “SomeController”, null, new {id = “someID” }) %> Which produces teh following HTML: … Read more

ActionLink htmlAttributes

The problem is that your anonymous object property data-icon has an invalid name. C# properties cannot have dashes in their names. There are two ways you can get around that: Use an underscore instead of dash (MVC will automatically replace the underscore with a dash in the emitted HTML): @Html.ActionLink(“Edit”, “edit”, “markets”, new { id … Read more