Solved

CompareValidator Problem

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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help with error when uploading excel file 3 29
Deploying to Azure 3 29
VB.Net WebRequest Code from JSON curl 9 16
insert value of checklistbox checked 4 27
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

803 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