Jan 31

,,The MVC platform: more form extension methods

Posted in ASP.NET MVC      Comments Off on ,,The MVC platform: more form extension methods

I’ve already talked about several method extensions helpers for injecting forms in a page. However, the latest release has introduce a couple more methods for doing that and I’ve thought I’d write a quick post on those new methods.

Basically, you’ll have several overloads named BeginRouteForm which let you set the form’s action method from a specific route. As you’d expect, you use it the same way you use the “Old” BeginForm method (check this post to get more info on what I mean). Here’s a quick example of what I mean:

<% using( var frm = Html.BeginRouteForm("DefaultRoute")) {%>
…//control definition

In the previous example, I’m using the simplest of the overloads: it only takes the name of the route that you want to use to build the form’s action url. As I’ve said, there are others (too much to put here so I’ll just redirect you to the FormExtension.cs file.