ASP.NET 2.0 RangeValidator

How can today's date be dynamically put in the MaximumValue of a RangeValidator for dates in a FormView without hardcoding?
ksfokAsked:
Who is Participating?
 
ThogekCommented:
How about settig the MaximumValue property to something like
    DateTime.Today.ToString()
    DateTime.Today.ToString("yyyy/MM/dd")

More about RangeValidator.MaximumValue at http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemwebuiwebcontrolsrangevalidatorclassmaximumvaluetopic.asp.
0
 
jroth-hajCommented:
Hello,
you should set it in the the "code behind".
Search for the best event to do this. then set the property.
Which is then best event  depends on the structure of your site.
0
 
ksfokAuthor Commented:
The following code:
Control myControl = FindControl("valHireDateRange");
generates:
The type or namespace name 'Control' could not be found (are you missing a using directive or an assembly reference?)

Please advise.
0
 
jroth-hajCommented:
try this
RangeValidator myControl = ctype(FindControl("myDateRangeValidator"),RangeValidator);
myControl .valHireDateRange=" DateTime.Today.ToString("yyyy/MM/dd")"
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.