Re: Dynamicly Added Range Validator Acting Goofy
From: Peter Blum (PLBlum_at_Blum.info)
Date: 09/16/04
- Next message: Peter Blum: "Re: Validation Summary - controlling order that error messages are listed"
- Previous message: Bruce Parker: "RE: Updating control collection from nested property"
- In reply to: Jim Craddock via .NET 247: "Dynamicly Added Range Validator Acting Goofy"
- Messages sorted by: [ date ] [ thread ]
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>
- Next message: Peter Blum: "Re: Validation Summary - controlling order that error messages are listed"
- Previous message: Bruce Parker: "RE: Updating control collection from nested property"
- In reply to: Jim Craddock via .NET 247: "Dynamicly Added Range Validator Acting Goofy"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|