How can I use a prefix for the fields in my strongly typed View?

Posted by deadtime on Stack Overflow See other posts from Stack Overflow or by deadtime
Published on 2010-03-19T13:29:23Z Indexed on 2010/03/19 13:31 UTC
Read the original article Hit count: 221

Hi,

I have an EditProfile action in my PersonController, that finds a Person object by ID and does return View(person). The EditProfile view has a bunch of fields that should be filled in with the information from the Person object. One of the fields is named "Person.FirstName", and is not filled in automatically when the View is rendered. However, if I rename the textbox to "FirstName", it gets filled in.

My question is: How can I specify to the view that it should use the "Person" prefix when filling in the information from the Person object?

The reason I want to do this is because of consistency - in some of my views I allow the user to edit more than one object at the same time, and use prefixes in order to bind these correctly.

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about strongly-typed-view