Incompatibilities in MVC futures

As has been posted on a few other blogs, there are some features of ASP.NET MVC 2 Futures that don't play nicely together.

Two features in particular are the validation (both MS Ajax and JQuery) and the generic form methods.

Here's a (working) example of a very simple form with the plain, non-generic MVC method:
<% Html.EnableClientValidation(); %>
 <% using (Html.BeginForm("Register", "Account", FormMethod.Post, new { model = "" })) { %>
 <%: Html.TextBoxFor(m => m.UserName) %>
 <%: Html.ValidationMessageFor(m => m.UserName) %>
 <input type="submit" value="Register" />
<% } %>

But the following does not work:
<% Html.EnableClientValidation(); %>
<% using (Html.BeginForm(x => x.Register(null))) { %>
  <%: Html.TextBoxFor(m => m.UserName) %>
  <%: Html.ValidationMessageFor(m => m.UserName) %>
  <input type="submit" value="Register" />
<% } %>


When this is run, it produces a JavaScript error along the lines of "formElement is null".

I do not  currently have a workaround for this (other than using the plain method). But it looks to me like the problem lies in the default ids for the form elements which the regular ASP.NET MVC method produces. The non-generic method creates an id for each form on the page (form0, form1, ...) but Futures does not.
comments powered by Disqus