In this lesson, you will learn how to set a display format and an edit mask to a business class property. For this purpose, the Task.StartDate, Task.DueDate, Task.PercentCompleted and PhoneNumber.Number properties' display format will be customized u…
在本节中,您将验证电影控制器生成的编辑方法(Edit action methods)和视图.但是首先将修改点代码,使得发布日期属性(ReleaseDate)看上去更好.打开Models \ Movie.cs文件,并添加高亮行如下所示: using System; using System.ComponentModel.DataAnnotations; using System.Data.Entity; namespace MvcMovie.Models { public class Movie…
1.在Model类里面添加验证,代码如下: public class Movie { public int ID { get; set; } [StringLength(,MinimumLength=,ErrorMessage="主题的长度必须在3到60个字符")] public string Title { get; set; } [Display(Name="Release Date")] [DataType(DataType.Date)] [DisplayFo…