i have two properties in model class:
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
here,StartDate
should be always less than EndDate
is there any data annotation for this in asp.net mvc
i have two properties in model class:
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
here,StartDate
should be always less than EndDate
is there any data annotation for this in asp.net mvc
There is the option to write your own custom attribute, as shown in this answer.
Another option is to use Foolproof (available from Nuget).
public class EventViewModel
{
[Required]
public string Name { get; set; }
[Required]
public DateTime Start { get; set; }
[Required]
[GreaterThan("Start")]
public DateTime End { get; set; }
}