我在 mvc 中有这个模型,具有各种验证属性,所有这些都提供错误消息
public class Images
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int ImageId { get; set; }
[Required(ErrorMessage="Please enter your first name")]
public string SubmitterFirstName { get; set; }
[Required(ErrorMessage = "Please enter your surname name")]
public string SubmitterLastName { get; set; }
[ExistingFileName]
public string NameOfImage { get; set; }
[StringLength(140, ErrorMessage="Please reduce the length of your description to below 140 characters")]
[DataType(DataType.MultilineText)]
public string DescriptionOfImage { get; set; }
public string ImagePath { get; set; }
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public DateTime DateAdded { get; set; }
}
这些错误消息中的每一个都出现在它们正在验证的(在这种情况下)文本框的一侧,有没有办法在一个视图中将它们全部组合在一起 a <div>
?如:
<div id="errorMessages">
//Errors appear here
<div>