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

x
?
Solved

Using a Compare validator for Time

Posted on 2011-09-22
2
Medium Priority
?
783 Views
Last Modified: 2012-05-12
I have two dropdowns on a form.  One for the start time and one for the end time.  Before submitting the form I'd like to insure that the end time is not less than the start time.

So, if the user does this

Start Time: 12:00 PM
End Time: 11:00 AM

the CompareValidator would fire.  

I can't get the CompareValidator to fire though.  Am I doing something wrong?  Please see code.
<asp:CompareValidator ID="CompareValidator2" runat="server" 
    ErrorMessage="Your End Time cannot be less than you Start Time." 
    ControlToCompare="ddlEndTime" 
    Operator="LessThan" 
    ControlToValidate="ddlStartTime" 
    Text="*" 
    Display="Dynamic">
</asp:CompareValidator>

Open in new window

0
Comment
Question by:cdemott33
2 Comments
 
LVL 15

Accepted Solution

by:
pateljitu earned 2000 total points
ID: 36581588
Try using custom validation, please see this article:

http://zubairdotnet.blogspot.com/2008/11/using-customvalidator-to-compare-time.html

Also CompareValidator will handle: String, Integer, Double, Date, currency

http://msdn.microsoft.com/en-us/library/system.web.ui.mobilecontrols.comparevalidator.type.aspx
0
 

Author Closing Comment

by:cdemott33
ID: 36581631
Thank You!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses
Course of the Month10 days, 22 hours left to enroll

885 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