views:

31

answers:

1

There seems to be no extension method to include some arbitrary route values that normally I would expect to go into the querystring.

Old code:

<%: Html.ActionLink(Model.ParentMessage.Category.Text, "index", null, new { category = Model.ParentMessage.CategoryID }, new { })%>

I want to change it to this but it takes the category as an HTML attribute.

<%: Html.ActionLink(Model.ParentMessage.Category.Text, MVC.Feedback.Index(), new { category = Model.ParentMessage.CategoryID })%> 

Just checking this isn't already possible before I write my own extension method as surely this was already accounted for?

+1  A: 

Yes, it's there! :) See the doc (http://mvccontrib.codeplex.com/wikipage?title=T4MVC_doc). Look for "Adding additional route parameters".

e.g. either:

<%: Html.ActionLink(Model.ParentMessage.Category.Text, MVC.Feedback.Index().AddRouteValue(category, Model.ParentMessage.CategoryID))%>

or

<%: Html.ActionLink(Model.ParentMessage.Category.Text, MVC.Feedback.Index().AddRouteValues(new { category = Model.ParentMessage.CategoryID }))%>
David Ebbo
Non other than David Ebbo himself :)
BritishDeveloper