Solved

CompareValidator Problem

Posted on 2012-03-16
5
235 Views
Last Modified: 2012-03-22
I'm sure this is a simple mistake but I have a CompareValidator that appears to be comparing the values within the text boxes as String vs Integers.  When I enter 3 in the txtCapacity and 15 in txtMaxCapacity the validation is triggered as an error.  What am I doing wrong.  Thanks!

This is my compare validator
<asp:CompareValidator ID="CompareValidator9" runat="server" 
                         ControlToCompare="txtCapacity" ControlToValidate="txtMaxCapacity" 
                         ErrorMessage="CompareValidator" Operator="GreaterThanEqual" Type="Integer"></asp:CompareValidator>

Open in new window


This is the textboxes
<td>Daily Capacity:*</td>
                            <td>
                                <asp:TextBox runat="server" ID="txtCapacity" MaxLength="3" Columns="10" 
                                    Width="201px" />
                            </td>
                        </tr> 
                          <tr>
                            <td>Max Open Capacity:*</td>
                            <td>
                                <asp:TextBox runat="server" ID="txtMaxCapacity" MaxLength="3" Columns="10" 
                                    Width="201px" />
                            </td>

Open in new window

0
Comment
Question by:rcowen00
  • 3
5 Comments
 
LVL 74

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 250 total points
Comment Utility
When you say "Operator='GreaterThanEqual'" you are indicating you want txtCapacity's value to be greater than or equal to txtMaxCapacity's value. Try switching to "Operator='LessThanEqual'".
0
 

Author Comment

by:rcowen00
Comment Utility
Switched it and I get the same thing
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 250 total points
Comment Utility
>ControlToCompare="txtCapacity" ControlToValidate="txtMaxCapacity"

Aren't those wrong way around?
0
 

Author Comment

by:rcowen00
Comment Utility
I have tried mixing it up every which way.  It will validate as expected if I enter txtCapacity=4 and txtMaxCapacity=5 but if I enter txtCapacity=4 and txtMaxCapacity=12 then it triggers it as txtMaxCapacity is less than txtCapacity.  I have even tried setting up a custom validator but I get the same results.  Am I inadvertently assigning the field as text and not realizing it???
0
 

Author Closing Comment

by:rcowen00
Comment Utility
The problem was caused by 2 validation tags and one was correct and the other incorrect.  Once I removed the incorrect one everything fired correctly
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video discusses moving either the default database or any database to a new volume.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

772 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now