tags:

views:

36

answers:

2

Could someone show me the syntax of an Html.ActionLink that will produce a hyperlink that looks like this:

<a h ref="/mycontroller/myaction/67">mylinktext</a>

thanks. Terrence

+1  A: 

To generate a link, use the HtmlHelper and the Action extension...

<%= Html.ActionLink ("mycontroller", "myaction", new { id = 67 }) %>
Kieron
Thank you for your response Kieron.
Terrence
+1  A: 

It depends more on how you set up your routes. But if you only have the default route and myaction takes one parameter named id it can look like this:

<%=Html.ActionLink("mylinktext", "myaction", "mycontroller", new { id = 67 }, null) %>

Or, if you want and have mvc features or mvc2, it can look like this:

<%=Html.ActionLink<mycontroller>(x => x.myaction(67), "mylinktext")%>
Mattias Jakobsson
Thank you for your response Mattias.
Terrence