Top "Data-annotations" questions

Data Annotations are used by frameworks such as ASP.

How do I specify the columns and rows of a multiline Editor-For in ASP.MVC?

In ASP.MVC 3, how do I specify the columns and rows for a multiline EditorFor (textarea)? I am using [UIHint("…

asp.net-mvc razor data-annotations
ASP.Net MVC DisplayFormat

In my model I have the following DataAnnotations on one of my properties [Required(ErrorMessage = "*")] [DisplayFormat(DataFormatString = "{0:d}")] [DataType(DataType.…

asp.net-mvc data-annotations
The specified value does not conform to the required format yyyy-MM-dd

I have a .Net MVC 5 application that is using Data Annotations, Entity-Framework Jquery 2.1.3 and Jquery UI 1.11.4. When I render an …

jquery asp.net-mvc google-chrome datetime data-annotations
Data Annotation to validate confirm password

My User model has these data annotations to validate input fields: [Required(ErrorMessage = "Username is required")] [StringLength(16, ErrorMessage = "Must be …

c# asp.net data-annotations
Error messages for model validation using data annotations

Given the following classes: using System.ComponentModel.DataAnnotations; public class Book{ public Contact PrimaryContact{get; set;} public Contact SecondaryContact{get; …

c# asp.net-mvc validation annotations data-annotations
Why is DisplayFormat DataFormatString not working?

I have a property in my view model as follows: [Editable(false)] [Display(Name = "Date")] [DisplayFormat(DataFormatString = "{0:yyyy/MM/dd}", …

asp.net-mvc asp.net-mvc-4 data-annotations
Conditionally required property using data annotations

I have a class like this: public class Document { public int DocumentType{get;set;} [Required] public string Name{get;set;} […

c# data-annotations requiredfieldvalidator required
Using DataAnnotations to compare two model properties

How would I go about writing a custom ValidationAttribute that compares two fields? This is the common "enter password", "confirm …

c# asp.net-mvc validation data-annotations
How to change default validation error message in ASP.NET MVC?

Say I have this property in my model: [DisplayName("test")] [Required(ErrorMessage = "required")] public DateTime? SomeDate { get; set; } when you …

asp.net-mvc asp.net-mvc-2 data-annotations
How to create Custom Data Annotation Validators

Wanting to create custom data annotation validation. Are there any useful guides / samples on how to create them? Firstly: StringLength …

asp.net asp.net-mvc-2 data-annotations