Change the Display field name Design field specification
1. References
1 using System.ComponentModel; 2 using System.ComponentModel.DataAnnotations;
2.DisplayName value
Public classBook { Public intBookID {Get;Set; } [DisplayName ("ISBN")] Public stringISBN {Get;Set; } [DisplayName ("Book name:")] [Required (ErrorMessage="name of the book must be filled")] Public stringBookName {Get;Set; } [DisplayName ("author")] [Required (ErrorMessage="The author must fill in")] Public stringAuthor {Get;Set; } [DisplayName ("Publishing House")] [Required (ErrorMessage="Publishing House must fill in")] Public stringPress {Get;Set; } [DisplayName ("Publication date")] [Required (ErrorMessage="date of publication must be filled")] PublicDateTime Pressdate {Get;Set; } [DisplayName ("Pricing:")] Public decimalPrice {Get;Set; } [DisplayName ("Size:")] Public stringSize {Get;Set; } [DisplayName ("Weight:")] Public Double? Weight {Get;Set; } [DisplayName ("Folio:")] Public int? Format {Get;Set; } }
3. Set field Range
[Stringlength ()]
[Stringlength (ten, minimumlength=2)]
Range Specifies the numeric range
[Range (0,10000)]
C # MVC Pattern Learning Notes _ data validation