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

enter image description here

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

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -