Solved

ASP.NET 2.0 RangeValidator

Posted on 2007-03-31
4
1,142 Views
Last Modified: 2011-10-03
How can today's date be dynamically put in the MaximumValue of a RangeValidator for dates in a FormView without hardcoding?
0
Comment
Question by:ksfok
  • 2
4 Comments
 
LVL 1

Expert Comment

by:jroth-haj
ID: 18830033
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
 

Author Comment

by:ksfok
ID: 18830912
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
 
LVL 15

Accepted Solution

by:
Thogek earned 250 total points
ID: 18831290
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
 
LVL 1

Assisted Solution

by:jroth-haj
jroth-haj earned 250 total points
ID: 18831551
try this
RangeValidator myControl = ctype(FindControl("myDateRangeValidator"),RangeValidator);
myControl .valHireDateRange=" DateTime.Today.ToString("yyyy/MM/dd")"
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question