Reputation: 5955
I'm building a form in ASP.NET MVC3 + Razor that posts to a PHP page which uses a different convention for naming the input fields. I need to make MVC's field names conform to the names that the PHP page is using. Instead of the input name being Customer.EmailAddress
, I need the field name to be customer[email_address]
.
I've been using the Html.TextBoxFor
, Html.LabelFor
and Html.ValidationMessageFor
methods on other pages, and I'd like to get the same functionality of generating validation from the attributes on my viewmodel. How do I customize the input name that Html.TextBoxFor is generating, and still get the validation behavior?
I've seen the Bind attribute, but that only seems to affect data being received by the server, not being rendered by the server.
Upvotes: 1
Views: 392
Reputation: 5955
So it was easier than I thought. For anyone trying to solve this problem, here's what I did
@Html.EditorFor(model => model.RegistrationDetails.Email, null, "customer[email_address]")
Upvotes: 1