Solved

CompareValidator Problem

Posted on 2012-03-16
5
238 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 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 250 total points
ID: 37731569
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
ID: 37731848
Switched it and I get the same thing
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 250 total points
ID: 37733824
>ControlToCompare="txtCapacity" ControlToValidate="txtMaxCapacity"

Aren't those wrong way around?
0
 

Author Comment

by:rcowen00
ID: 37736176
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
ID: 37754832
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Sql server, import complete table, using vb.net 9 43
asp.net mvc5 6 20
Calculate number of nights between two dates 5 53
C# MVC Insert Multiple Row into DB 2 30
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

789 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