Solved

ASP.NET 2.0 RangeValidator

Posted on 2007-03-31
4
1,143 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

733 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