Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

CompareValidator and Todays Date

Posted on 2004-04-12
3
Medium Priority
?
4,150 Views
Last Modified: 2012-08-14
Hi Experts:
I am trying to compare a textbox field to todays date so that the user can not enter something less than today.

Dim static strToday as String = CStr(Today)

<asp:CompareValidator Runat=server ID= CompareValidator1 ErrorMessage="Date must be AFTER Today" ControlToValidate = "txtStartDate" ValueToCompare="strToday" Type=Date></asp:CompareValidator>

This gives error:
The value 'strToday' of the ValueToCompare property of 'CompareValidator1' cannot be converted to type 'Date'.

I am fairly sure it is because strToday = #4/12/2004# and the # need to be stripped off.  Do I need to create a function to strip this off?  There must be an easier way.
cheers,
dwc
0
Comment
Question by:dwcorwith
3 Comments
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 10806200
you might try:

Dim static strToday as String = Date.Today.ToShortDateString


AW
0
 
LVL 7

Accepted Solution

by:
dante469 earned 800 total points
ID: 10807663
ValueToCompare= refs to a constant not a variable.....

Please try this....

.aspx page---->

<asp:CompareValidator Runat=server ID="CompareValidator1" ErrorMessage="Date must be AFTER Today" ControlToValidate = "txtStartDate" ValueToCompare="1/1/1980" Type=Date></asp:CompareValidator>

codebehind on load--->

CampareValidator1.ValueToCompare = today

Have Fun,
dante
0
 
LVL 2

Author Comment

by:dwcorwith
ID: 10808264
Dante,
After respelling CompareValidator1 it works great!  
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

926 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