Two fields with the same name

Posted by H. Abraham Chavez on Stack Overflow See other posts from Stack Overflow or by H. Abraham Chavez
Published on 2010-04-16T15:40:21Z Indexed on 2010/04/16 16:13 UTC
Read the original article Hit count: 350

Filed under:

I have a ViewModel class to encapsulate "Personal" and "Business" models. My problem is that both models have a property called "Email" and the model binding is not able to make a distinction between the too.

I read that [Bind(Prefix = ... is used to resolved this issue, but I have not been able to see a concise example on how to achieve this.

SO community please help.

public class BusinessFormViewModel
{
    public Business Business { get; set; }
    public ContactPerson ContactPerson { get; set; }

    public BusinessFromView(Business business, ContactPerson contactPerson)
    {
        Business = business;
        ContactPerson = contactPerson;
    }
}

© Stack Overflow or respective owner

Related posts about asp.net-mvc