Reputation: 772
If I do not want to do this in my View Markup,
<%=Html.RouteLink("Listings", "Listings", new {market = "Austin", state = "Texas", pagenumber = 3 })%>
what would be the best approach to creating links in MVC 2? I have a HTML helper to build a custom link but all it is doing is acting as a wrapper around RouteLink (or ActionLink). I would want something more elegant and one that has a shorter syntax. If I build my links in a controller, how do I push it into the view? Via ViewData? (hope not). Or would it be part of the ViewModel?
Upvotes: 2
Views: 347
Reputation: 3034
I like using T4MVC better than MVC Futures ActionLink helpers. You line would look like this:
<%:Html.ActionLink("Listings", MVC.Listings.Index("Austing", "Texas", 3)) %>
http://mvccontrib.codeplex.com/wikipage?title=T4MVC
Upvotes: 2
Reputation: 15663
Long term, I think the Html.ActionLink which you see in the MVC Futures library is the way to fly:
<%= Html.ActionLink<ListingsController>(x => x.Listings("Austin", "Texas", 3)) %>
Using your HtmlHelpers, even if they are just wrappers around the current magic-string based functionality as it at least reduces your frontage to magic strings and provides a single point to change.
I wouldn't get involved in building links on the back-end if I could help it in an effort to make syntactical sugar.
Upvotes: 2