Board index » dotnet-framework-aspnet » Bug in Compare Validator??

Bug in Compare Validator??

2004-10-16 12:15:25 AM
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
-
 

Re:Bug in Compare Validator??

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
mitchell@4guysfromrolla.com
www.4GuysFromRolla.com
* When you think ASP.NET, think 4GuysFromRolla.com!
Andrew wrote:
Quote
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


-

Re:Bug in Compare Validator??

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]" <mitchell@4guysfromrolla.com>wrote in message
Quote
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
mitchell@4guysfromrolla.com
www.4GuysFromRolla.com

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


Andrew wrote:
Quote
I just ran into this on a page I am building. I needed to ensure the
user
Quote
typed in a value less than 60. I added a Compare Validator, bound it to
the
Quote
input text box, set Operator="LessThan", and ValueToCompare="60". Now,
if I
Quote
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
Quote
in 07, 08, or 09, I get no error. Uh, say what? Why does 7 bomb when
07
Quote
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


-