473,408 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

CompareValidator for dates > than today

I am trying to check the date of my field to check if it is greater that
today, but I am getting an error.

I am using :

<asp:CompareValidator runat="server"
ControlToCompare="RequestedStartDate"
Operator="GreaterThan"
Display="Dynamic"
ValueToCompare = DateTime.Today.ToShortDateString()
Type="Date" text="<br>Invalid Start Date"/>

But it gives me an error:

The value 'DateTime.Today()' of the ValueToCompare property of '' cannot
be converted to type 'Date'

I also tried DateTime.Today(), but got the same error. How would I do this?

Thanks,

Tom
Jan 13 '06 #1
2 10345

tshad wrote:
I am trying to check the date of my field to check if it is greater that
today, but I am getting an error.

I am using :

<asp:CompareValidator runat="server"
ControlToCompare="RequestedStartDate"
Operator="GreaterThan"
Display="Dynamic"
ValueToCompare = DateTime.Today.ToShortDateString()
Type="Date" text="<br>Invalid Start Date"/>

But it gives me an error:

The value 'DateTime.Today()' of the ValueToCompare property of '' cannot
be converted to type 'Date'

I also tried DateTime.Today(), but got the same error. How would I do this?

Thanks,

Tom


How about this:

ValueToCompare = '<%= DateTime.Today.ToShortString() %>'

put a semi-colon to the end of the ToShortString() if using C#. See if
that works

Jan 13 '06 #2

"tdavisjr" <td******@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...

tshad wrote:
I am trying to check the date of my field to check if it is greater that
today, but I am getting an error.

I am using :

<asp:CompareValidator runat="server"
ControlToCompare="RequestedStartDate"
Operator="GreaterThan"
Display="Dynamic"
ValueToCompare = DateTime.Today.ToShortDateString()
Type="Date" text="<br>Invalid Start Date"/>

But it gives me an error:

The value 'DateTime.Today()' of the ValueToCompare property of '' cannot be converted to type 'Date'

I also tried DateTime.Today(), but got the same error. How would I do this?
Thanks,

Tom


How about this:

ValueToCompare = '<%= DateTime.Today.ToShortString() %>'

put a semi-colon to the end of the ToShortString() if using C#. See if
that works

That was what I was looking for.

Thanks,

Tom
Jan 17 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: edi | last post by:
Hi, Are there any differences between CompareValidator.ControlToCompare and CompareValidator.ControlToValidate? For example if I have TextBox controls: TextBox1 and TextBox2 what are the...
0
by: Sjaakie Helderhorst | last post by:
Hi, Somehow pushing an image-button doesn't trigger the CompareValidator, resulting in errors when entering string characters. Could someone please tell me what I did wrong? Thanks in advance!...
1
by: Jorge EA | last post by:
Hi there, According to the following article, a textbox for a date entry field can be validated with a CompareValidator: ...
2
by: Eric Maia | last post by:
I have a textbox (StartDateTextBox) in a UserControl on my page, that is supposed to have a date entered into it. I have a RequiredFieldValidator that has its ControlToValidate property set to the...
3
by: CyberLotus | last post by:
Hi, I wish to validate the date a user has entered against the format dd-mmm-yyyy using the CompareValidator, but it does not work. Does anybody have a simple solution please? Many thanks...
0
by: gauthier | last post by:
Hi, I'm developing a web application available in multiple languages. When we switch language (via a drop down list), we switch the culture of the current thread: ...
3
by: THaskell | last post by:
I am using a comparevalidator to make sure that a date for a scheduling app is not in the past. <asp:CompareValidator id="cvSD" runat="server" ControlToValidate="txtStartDate"...
1
by: R.A.M. | last post by:
Hello, (Sorry for my English...) Could you help me please? I have a problem with CompareValidator control which makes the load of my page infinitive. Here's the code: Date of birth:...
0
by: =?Utf-8?B?VmFuY291dmVyTWlrZQ==?= | last post by:
Hi there, I have a web app written in 1.1 in ASP.net and C#. In the web app, I need to compare two dates (from and to) from two textboxes on webpage to make sure the to date is greater than or...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.