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

Putting HTML inside Html.ActionLink(), plus No Link Text?

Instead of using Html.ActionLink you can render a url via Url.Action <a href=”https://stackoverflow.com/questions/1974980/<%= Url.Action(“Index”, “Home”) %>”><span>Text</span></a> <a href=”https://stackoverflow.com/questions/1974980/@Url.Action(“Index”, “Home”)”><span>Text</span></a> And to do a blank url you could have <a href=”https://stackoverflow.com/questions/1974980/<%= Url.Action(“Index”, “Home”) %>”></a> <a href=”https://stackoverflow.com/questions/1974980/@Url.Action(“Index”, “Home”)”></a>

Html.ActionLink as a button or an image, not a link

I like to use Url.Action() and Url.Content() like this: <a href=”https://stackoverflow.com/questions/596444/@Url.Action(“MyAction”, “MyController”)”> <img src=”@Url.Content(“~/Content/Images/MyLinkImage.png”)” /> </a> Strictly speaking, the Url.Content is only needed for pathing is not really part of the answer to your question. Thanks to @BrianLegg for pointing out that this should use the new Razor view syntax. Example has been updated accordingly.

HTML.ActionLink method

I think what you want is this: ASP.NET MVC1 Html.ActionLink(article.Title, “Login”, // <– Controller Name. “Item”, // <– ActionMethod new { id = article.ArticleID }, // <– Route arguments. null // <– htmlArguments .. which are none. You need this value // otherwise you call the WRONG method … // (refer to comments, below). ) … Read more