Hi to All...
I am new to the MVC anybody give detailed notes about Data Annotations MVC 4
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
NitinRank #455 · 5.5K reputationPosted Mar 30, 2015, 10:39 PM EDT
In your models folder in MVC you create models. Now if you need to place validations on it you need to import the "using System.ComponentModel.DataAnnotations;" namespace.
Further for your properties you can use it like:
[Required(ErrorMessage="Please Enter ID")]
public int Id { get; set; }
[StringLength(15,MinimumLength=4)]
[Required(ErrorMessage = "Please Enter Name")]
public string Name { get; set; }
[Required(ErrorMessage = "Please Enter Price")]
public double Price { get; set; }
Follow the below links for detailed analysis:
MVC 4 Validation 1
MVC 4 Validation 2