Re: Dynamicly Added Range Validator Acting Goofy

From: Peter Blum (PLBlum_at_Blum.info)
Date: 09/16/04


Date: Thu, 16 Sep 2004 12:21:18 -0400

This sounds like the Type property has not been assigned. It defaults to
"String" which is very different from comparing integers. Set it to Integer.

--- Peter Blum
www.PeterBlum.com
Email: PLBlum@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Jim Craddock via .NET 247" <anonymous@dotnet247.com> wrote in message
news:OsMSCA2mEHA.3480@TK2MSFTNGP09.phx.gbl...
We add all the controls to our pages in the Page_load event. I recently
noticed that the range validator doesn't fail in all cases when it should.
If I set the min to 10 and the max to 1000 and add it dynamically, the value
50 will fail. If I change the 50 to 500 the value will pass. If I set the
minimum at 10 and the max at 500, the value 50 will pass, but any value
between 50 and 100 will fail, but 100 will pass - and it will only take
values that are FACTORS of 50. So, 100 will pass and 101-149 will fail with
150 succeeding.

Is this a bug in .NET?

Here is the HTML except from the page:
<span id="_ctl3" controltovalidate="t_7" errormessage="The value for Page
Size must be between 10 and 500<BR>" display="Dynamic"
evaluationfunction="RangeValidatorEvaluateIsValid" maximumvalue="500"
minimumvalue="10" style="color:Red;display:none;">The value for Page Size
must be between 10 and 500<BR></span>

Here is the code that added it:
Public Shared Function AddRangeValidator(ByVal ColNumber As Integer, ByVal
ColName As String, ByVal pl_hold As PlaceHolder, Optional ByVal minvalue As
Integer = -1, Optional ByVal maxvalue As Integer = 999)
Dim RFV As New RangeValidator
If minvalue <> -1 Or maxvalue <> -1 Then
RFV.ControlToValidate = "t_" & ColNumber.ToString
RFV.ErrorMessage = "The value for " & ColName & " must be"
If minvalue = -1 And maxvalue <> -1 Then
    RFV.ErrorMessage = RFV.ErrorMessage & " no more than " &
maxvalue.ToString() & "<BR>"
    RFV.MaximumValue = maxvalue
ElseIf maxvalue = -1 Then
    RFV.ErrorMessage = RFV.ErrorMessage & " at least " & minvalue.ToString()
& "<BR>"
    RFV.MinimumValue = minvalue
ElseIf minvalue <> -1 And maxvalue <> -1 Then
    RFV.ErrorMessage = RFV.ErrorMessage & " between " & minvalue.ToString()
& " and " & maxvalue.ToString() & "<BR>"
    RFV.MaximumValue = maxvalue
    RFV.MinimumValue = minvalue
End If
RFV.ErrorMessage = RFV.ErrorMessage & vbCrLf & vbCrLf & vbCrLf
RFV.Display = ValidatorDisplay.Dynamic
pl_hold.Controls.Add(RFV)
End If
End Function

--------------------------------
From: Jim Craddock

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>FBxZYCY12EyadX2ADOVEVA==</Id>



Relevant Pages

  • Re: Third times a charm? Date query question
    ... field is it a date field or text field that contains a string that looks ... Those both should fail as the appear to be incorrectly bracketed. ... I keep getting an error stating this expression ... How can I fix this and will the code work if fixed? ...
    (microsoft.public.access.queries)
  • Re: BJC HLCB thread
    ... The Renegade with Aaron ... Gregg running it. ... Low - The prick with the string and the card tricks. ... Goal - Go to a workshop - fail. ...
    (rec.juggling)
  • Re: Third times a charm? Date query question
    ... field is it a date field or text field that contains a string that looks ... Those both should fail as the appear to be incorrectly bracketed. ... I keep getting an error stating this expression ... How can I fix this and will the code work if fixed? ...
    (microsoft.public.access.queries)
  • Re: basic char and int array loading
    ... >will try to convert that input to a number and fail. ... in the stream's buffer now makes things understandable. ... is string or numeric. ... way in C++, to load an array with a combination of strings and numerics, ...
    (alt.comp.lang.learn.c-cpp)
  • Re: if EthType < StrToInt($05DC) then EthType := 0; // doesntwork!!
    ... Yes MinValue now is stored as a binary number and every four binary ... No. IntToHex is a string and a string can not be compared to a number ... EthType is already stored in binary, just compare its value. ...
    (alt.comp.lang.borland-delphi)