Bug in Compare Validator??

A

Andrew

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
 
S

Scott Mitchell [MVP]

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
(e-mail address removed)
http://www.4GuysFromRolla.com

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

Andrew

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,828
Latest member
LauraCastr

Latest Threads

Top