Welcome to Dream.In.Code
Become an Expert!

Join 150,217 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,114 people online right now. Registration is fast and FREE... Join Now!




CompareValidator control - Beginner problem

 
Reply to this topicStart new topic

CompareValidator control - Beginner problem

pietra
15 Nov, 2007 - 07:35 AM
Post #1

D.I.C Head
**

Joined: 8 Feb, 2007
Posts: 70


My Contributions
Hello, here I am again smile.gif and I have a problem - again... mad.gif

I'm following one book and I came upon this exercise

CODE

protected void Page_Load(object sender, EventArgs e)
    {
        CompareValidator1.ValueToCompare = DateTime.Now.ToString("d");
    }

protected void Button3_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            Response.Redirect("success.aspx");
        }
    }


Values set for CompareValidator
Text - "wrong date"
ControlToValidate - TextBox3
Operator - GreaterThan
Type - Date


Probem is when I type date greater than today's, I don't get redirected to "success.aspx". If I type anything else I get "Wrong date" error.

On that page I have few other validation controls, I think that shouldn't be a problem.

If you can help me, your help will be much appreciated. Thank you
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: CompareValidator Control - Beginner Problem
15 Nov, 2007 - 08:15 PM
Post #2

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 9,483



Thanked: 161 times
Dream Kudos: 9075
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
Well from what Im seeing, if you trype a date greater than DateTime.Now.ToString("d") then you're not going to get a success response. Your value to compare is DateTime.Now.ToString("d") so DateTime.Now + 1.ToString("d) would not pass your validation.

Theres always a chance that I'm completely misunderstanding you question (which is possible from time to time), in that case you need to provide a much more detailed explanation of what your problem is smile.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 05:30AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month