ASP.NET Core教程【三】实体字段属性、链接标签、并发数据异常、文件上传及读取
前文索引:
ASP.NET Core教程【二】从保存数据看Razor Page的特有属性与服务端验证
ASP.NET Core教程【一】关于Razor Page的知识
实体字段属性
public class Movie
{
public int ID { get; set; }
public string Title { get; set; }
[Display(Name = "Release Date")]
[DataType(DataType.Date)]
public DateTime ReleaseDate { get; set; }
public string Genre { get; set; }
public decimal Price { get; set; }
}
<label asp-for="Movie.Title" class="control-label"></label>
[StringLength(60, MinimumLength = 3)]
[Required]
[Range(1, 100)]
[RegularExpression(@"^[A-Z]+[a-zA-Z''-'\s]*$")]
[DataType(DataType.Currency)]
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}"]
[RegularExpression(@"^[A-Z]+[a-zA-Z''-'\s]*$"), Required, StringLength(30)]
链接标签
<a asp-page="./Edit" asp-route-id="@item.ID">Edit</a>
<a asp-page="./Details" asp-route-id="@item.ID">Details</a>
<a asp-page="./Delete" asp-route-id="@item.ID">Delete</a>