Groups | Blog | Home
all groups > asp.net > april 2006 >

asp.net : why is my range validator failing?


Darrel
4/16/2006 11:17:30 PM
I have this range validator:

<asp:rangevalidator id=RngVal_LGwidth runat="server" ErrorMessage="LG Width
needs to be between 10px and 2000px" EnableClientScript="False"
ControlToValidate="tbx_LGwidth" MaximumValue="1999" MinimumValue="10"
Display="Dynamic">(!)</asp:rangevalidator>

For some reason, it's triggering when my text box has a value of '200' or
higher (rather than 2000).

Why?

-Darrel

David Hogue
4/17/2006 12:00:00 AM
Hi Darrel,

There is no type set. Try adding type="Integer" somewhere in there. I
think it defaults to string which doesn't make much sense. I haven't
ever needed to validate the range of a string...

http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.basecomparevalidator.type(VS.80).aspx

--
David Hogue


[quoted text, click to view]
Teemu Keiski
4/17/2006 12:00:00 AM
You also need to specify the type of the data for it. Otherwise it is
assumed to be a string, and string evaluation is quite different from
evaluating numbers...

Specify additionally

Type="Integer" to the control declaration

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

[quoted text, click to view]

Darrel
4/17/2006 7:18:33 AM
[quoted text, click to view]

Ah! Right in front of me. Thanks!

Yea, that *is* weird...how does one even check the range of a string?

-Darrel

AddThis Social Bookmark Button