Bug in Compare Validator??

Discussion in 'ASP .Net Web Controls' started by Andrew, Oct 15, 2004.

  1. Andrew

    Andrew Guest

    I just ran into this on a page I am building. I needed to ensure the user
    typed in a value less than 60. I added a Compare Validator, bound it to the
    input text box, set Operator="LessThan", and ValueToCompare="60". Now, if I
    type in 1 through 6, or any double digit value less than 60 no problem.
    However... if I type in the numbers 7, 8, or 9, I get an error. If I type
    in 07, 08, or 09, I get no error. Uh, say what? Why does 7 bomb when 07
    does not? What is going on here?

    Here are steps to recreate the problem I am getting:
    1) Create a new blank WebForm
    2) Add a Text Box Web Control
    3) Add a Compare Validator Webcontrol and
    a) Set ErrorMessage="Value greater than 60"
    b) Set Operator="LessThan"
    c) Bind it to the text box above
    4) Add a Button Web Control
    5) Add a Validation Summary Web Control
    6) Run the page in the browser and try the numbers I mentioned above.

    I am using VB.Net as my language
    ..Net Framework 1.1 (v1.1.4322 SP1)
    MS Server 2k3 Enterprise Ed.
    MS Visual Studio 2K3 (v7.1.3088)

    -- Andrew
     
    Andrew, Oct 15, 2004
    #1
    1. Advertising

  2. Andrew, set the Type property of the CompareValidator to Integer, and
    things should work out. WHat I'd wager is happening is the
    CompareValidator's Type property is set to String, so it's aying, "The
    string '7' is not less than the string '60'."

    hth

    --

    Scott Mitchell

    http://www.4GuysFromRolla.com

    * When you think ASP.NET, think 4GuysFromRolla.com!


    Andrew wrote:
    > I just ran into this on a page I am building. I needed to ensure the user
    > typed in a value less than 60. I added a Compare Validator, bound it to the
    > input text box, set Operator="LessThan", and ValueToCompare="60". Now, if I
    > type in 1 through 6, or any double digit value less than 60 no problem.
    > However... if I type in the numbers 7, 8, or 9, I get an error. If I type
    > in 07, 08, or 09, I get no error. Uh, say what? Why does 7 bomb when 07
    > does not? What is going on here?
    >
    > Here are steps to recreate the problem I am getting:
    > 1) Create a new blank WebForm
    > 2) Add a Text Box Web Control
    > 3) Add a Compare Validator Webcontrol and
    > a) Set ErrorMessage="Value greater than 60"
    > b) Set Operator="LessThan"
    > c) Bind it to the text box above
    > 4) Add a Button Web Control
    > 5) Add a Validation Summary Web Control
    > 6) Run the page in the browser and try the numbers I mentioned above.
    >
    > I am using VB.Net as my language
    > .Net Framework 1.1 (v1.1.4322 SP1)
    > MS Server 2k3 Enterprise Ed.
    > MS Visual Studio 2K3 (v7.1.3088)
    >
    > -- Andrew
    >
    >
     
    Scott Mitchell [MVP], Oct 15, 2004
    #2
    1. Advertising

  3. Andrew

    Andrew Guest

    Scott,

    Thanks, and I just found that by reading a bit further in the book. Ok, egg
    on the face. :)

    I got a 4GFR fellow on the line?? Kewl....thank you for the outstanding
    articles, examples, and all the rest on that website. Please don't stop the
    flow!!

    -- Andrew


    "Scott Mitchell [MVP]" <> wrote in message
    news:...
    > Andrew, set the Type property of the CompareValidator to Integer, and
    > things should work out. WHat I'd wager is happening is the
    > CompareValidator's Type property is set to String, so it's aying, "The
    > string '7' is not less than the string '60'."
    >
    > hth
    >
    > --
    >
    > Scott Mitchell
    >
    > http://www.4GuysFromRolla.com
    >
    > * When you think ASP.NET, think 4GuysFromRolla.com!
    >
    >
    > Andrew wrote:
    > > I just ran into this on a page I am building. I needed to ensure the

    user
    > > typed in a value less than 60. I added a Compare Validator, bound it to

    the
    > > input text box, set Operator="LessThan", and ValueToCompare="60". Now,

    if I
    > > type in 1 through 6, or any double digit value less than 60 no problem.
    > > However... if I type in the numbers 7, 8, or 9, I get an error. If I

    type
    > > in 07, 08, or 09, I get no error. Uh, say what? Why does 7 bomb when

    07
    > > does not? What is going on here?
    > >
    > > Here are steps to recreate the problem I am getting:
    > > 1) Create a new blank WebForm
    > > 2) Add a Text Box Web Control
    > > 3) Add a Compare Validator Webcontrol and
    > > a) Set ErrorMessage="Value greater than 60"
    > > b) Set Operator="LessThan"
    > > c) Bind it to the text box above
    > > 4) Add a Button Web Control
    > > 5) Add a Validation Summary Web Control
    > > 6) Run the page in the browser and try the numbers I mentioned above.
    > >
    > > I am using VB.Net as my language
    > > .Net Framework 1.1 (v1.1.4322 SP1)
    > > MS Server 2k3 Enterprise Ed.
    > > MS Visual Studio 2K3 (v7.1.3088)
    > >
    > > -- Andrew
    > >
    > >
     
    Andrew, Oct 15, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Robbo
    Replies:
    0
    Views:
    325
    Robbo
    Oct 30, 2003
  2. dotnet beginner

    Compare Validator

    dotnet beginner, Nov 12, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    457
    Mike Moore [MSFT]
    Nov 13, 2003
  3. A.M

    Compare Validator

    A.M, Jun 23, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    3,114
    scoutdickens
    Aug 23, 2007
  4. TN Bella
    Replies:
    0
    Views:
    479
    TN Bella
    Jul 2, 2004
  5. Kaja
    Replies:
    0
    Views:
    606
Loading...

Share This Page