views:

23

answers:

0

Hello to everyone Please help

I have below classes

[Bind(Exclude = "Id")]
public class Account
{
    public Account()
    {
        User = new User {Account = this};
        UserDetails = new UserDetails {Account = this};
    }
    public virtual int Id { get; private set; }
    public virtual User User { get; set; }
    public virtual UserDetails UserDetails { get; set; }
}


[Bind(Exclude = "Id,Account,Roles")]
public class User
{
    public virtual int Id { get; private set; }
    //public virtual string     Login { get; set; }

    [Required(ErrorMessage = "*")]
    [Email]
    public virtual string Email { get; set; }

    [Required(ErrorMessage = "*")]
    public virtual string Password { get; set; }

    public virtual UserRole Roles { get; set; }
    public virtual Account Account { get; set; }
}

[Bind(Exclude = "Id,Account,Status,CreateUpdateInfo,Title")]
public class UserDetails
{
    public virtual int Id { get; private set; }

    [Required(ErrorMessage = "*")]
    public virtual Account Account { get; set; }

    [Required(ErrorMessage = "*"), DisplayName("Forename")]
    public virtual string FirstName { get; set; }

    [Required(ErrorMessage = "*"), DisplayName("Surname")]
    public virtual string LastName { get; set; }

    [Required(ErrorMessage = "Hello. I'm message")]
    public virtual Title Title { get; set; }

    public virtual string DOB { get; set; }

    [DisplayName("Ni Number")]
    public virtual string NiNumber { get; set; }

    //Communication info
    [Required(ErrorMessage = "*"), DisplayName("Contact Phone")]
    public virtual string ContactPhone { get; set; }

    [DisplayName("Mobile")]
    public virtual string MobilePhone { get; set; }

    //Address
    public virtual Address MailingAddress { get; set; }

    public virtual UserStatus Status { get; set; }

    //Created, Updated
    public virtual CreateUpdateInfo CreateUpdateInfo { get; set; }


    public UserDetails()
    {
        Title = new Title();
        MailingAddress = new Address();
        Status = UserStatus.Inactive;
        CreateUpdateInfo = new CreateUpdateInfo();
    }
}

public class Title : BaseEntity
{

}

public class BaseEntity
{
    public virtual int Id { get; private set; }
    public virtual string Name { get; set; }
}

I'm trying to create new account

I've created the view with lots of text boxes and one drop down list

<%= Html.LabelFor(model => model.UserDetails.Title) %> <%= Html.DropDownListFor(model => model.UserDetails.Title.Id, (IEnumerable)ViewData["titleList"], "- choose -") %> <%= Html.ValidationMessageFor(model => model.UserDetails.Title.Id) %>

When I try to sumbit form mvc tells me that "The Id field is required." Ok I really need it, but I want to change this message to "*" I can't understand how this message appear because I don' have the required attribute under Id property of Title class ? Thank you