According to this question, I am supposed to be able to write something like this:
@Html.ActionLink( "Delete", "Delete", "Message", new { data_id=id, @class="delete" } )
or as a happy T4MVC user can do:
@Html.ActionLink( "Delete", MVC.Message.Actions.Delete(), new { data_id=id, @class="delete" } )
And get the underscore in "data_id" replaced during rendering:
<a href="/message/delete" class="delete" data-id="42">Delete</a>
However, this seems not to work in the MVC 4 beta. Anyone else seeing this problem?
Is it an intentional change, and if so, what should I do instead?
UPDATE - HOW TO FIX (MANUALLY)
I've applied the following changes to the T4MVC.tt file, which fixes the problem in the generated code:
public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, ActionResult result, object htmlAttributes, string protocol = null, string hostName = null, string fragment = null) {
//was: return ActionLink(htmlHelper, linkText, result, new RouteValueDictionary(htmlAttributes), protocol, hostName, fragment);
return htmlHelper.RouteLink(linkText, null, protocol, hostName, fragment, result.GetRouteValueDictionary(), HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes));
}
UPDATE 2 - FIX AVAILABLE
David Ebbo was lightning fast at responding to the reported issue and has already merged the above fix into T4MVC.
UPDATE 3 - FIX THE FIX
Quite embarassingly, the original fix submitted did in fact not work, as it still called an invalid overload. I've now modified the code to do the same as MVC does internally (using their helper method), and notified David to have it included in T4MVC. Grab 2.6.70 from codeplex or update using NuGet when its released, probably shortly.
In MVC, HTML Helper can be considered as a method that returns you a string. This string can describe the specific type of detail of your requirement. Example: We can utilize the HTML Helpers to perform standard HTML tags, for example HTML<input>, and any <img> tags.
The ASP.NET MVC framework is a lightweight, highly testable presentation framework that (as with Web Forms-based applications) is integrated with existing ASP.NET features, such as master pages and membership-based authentication. The MVC framework is defined in the System. Web.
Try
@Html.ActionLink( "Delete", "Delete", "Message", null, new { data_id=id, @class="delete" } )
I think that becuase of all the overloads it is assuming your 4th parameter is the routeValues parameter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With