1

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.

1 Answer 1

1

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]")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.