DisplayName metadata does not show up on view

前端 未结 1 1477
温柔的废话
温柔的废话 2021-01-27 07:59

How will I show the correct DsiplayName on my view considering the following model.

<%@ Page Title=\"\" Language=\"C#\         


        
1条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-27 08:53

    You View is strongly typed to Project.Models.RegisterViewModel, however you are adding your Data Annotations to the User Object.

    Generally you would have:

    public class RegisterViewModel
    {
        [Required]
        [DisplayName("Email Login")]
        [DataType(DataType.EmailAddress)]
        [Email(ErrorMessage = "Invalid Email")]
        public String Email { get; set; }
    
        .....
        other properties
    }
    

    0 讨论(0)
提交回复
热议问题