Solved

CompareValidator + RangeValidator not working together

Posted on 2006-11-07
2
436 Views
Last Modified: 2008-06-17
I must be doing something really stupid here but I can't get the following logic to work.  I need the user to enter a numeric (double) figure into the textbox that is between 0 - 250.

So:
   "abc" is not valid
   0 is valid
   53.535 is valid
   250 is valid
   251 is not valid

The page code is as follows:

<asp:TextBox ID="txt_higher" runat="server" />
<asp:CompareValidator ID="cmpval1" runat="server" ControlToValidate="txt_higher" Operator="dataTypeCheck" Type="double" ValidationGroup="vg1" Text="Value in box 1 must be numeric." />
<asp:RangeValidator ID="rngval1" runat="server" ControlToValidate="txt_higher" MaximumValue="250" MinimumValue="0" Text="Value in box 1 must be 0-250." ValidationGroup="vg1" />
<br />
<br />
<asp:Button ID="btn" runat="server" Text="Validate" ValidationGroup="vg1" CausesValidation="true"  />

However if I enter 50 into the box, the page won't validate.  ASP.NET 2.0 seems to think that 50 does not lie between 0-250.  Am I going mad?
0
Comment
Question by:Rouchie
2 Comments
 
LVL 11

Accepted Solution

by:
ethoths earned 500 total points
ID: 17888895
It's doing a text compare. You need to tell it the type...


<asp:RangeValidator type="Double" ID="rngval1" runat="server" ControlToValidate="txt_higher" MaximumValue="250" MinimumValue="0" Text="Value in box 1 must be 0-250." ValidationGroup="vg1" />
0
 
LVL 25

Author Comment

by:Rouchie
ID: 17889212
Ah, so I'm not mad (well, not entirely!).  

Thanks ethoths
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying 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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

809 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