Monday, January 11, 2016

Display Annotations - ASP.NET MVC

ASP.NET MVC display annotations are pretty strait forward. Let's go for an example strait away.
I have an Employee class

        [Required]
        public virtual string Name { get; set; }

        public virtual string Address { get; set; }

        [DisplayName("Date of birth")]
        [DataType(DataType.Date)]
        public virtual DateTime DateOfBirth { get; set; }

        [Range(1, 5)]
        public virtual int Tier { get; set; }

        [DataType(DataType.Password)]
        public virtual string Password { get; set; }

        [DataType(DataType.MultilineText)]
        public virtual string Comments { get; set; }

        [DisplayName("Start date")]
        [DataType(DataType.Date)]
        public virtual DateTime StartDate { get; set; }

Output:


No comments:

Post a Comment