c# - MVC date range between min and max value -
i trying add range date in model.
i have added following property class
[required] [datatype(datatype.date)] [display(name = "date schedule")] [range(typeof(datetime), datetime.now.tostring("dd/mm/yyyy"), datetime.now.adddays(120).tostring("dd/mm/yyyy"), errormessage = "please select valid date")] public datetime? dateschedule { get; set; }
it gives me following error
how can assign min , max value dateschedule
? in calendar control should display date today
120 days
(in class have added 120 days).
attributes accept constants parameters.
we know datetime.now
isn't constant, changes depending on when code runs. , range attribute determined @ compile time.
you need create custom validator shown below :-
public class dateattribute : rangeattribute { ////your code }
Comments
Post a Comment