J
Jim Craddock via .NET 247
We add all the controls to our pages in the Page_load event. Irecently noticed that the range validator doesn't fail in allcases when it should. If I set the min to 10 and the max to1000 and add it dynamically, the value 50 will fail. If Ichange the 50 to 500 the value will pass. If I set the minimumat 10 and the max at 500, the value 50 will pass, but any valuebetween 50 and 100 will fail, but 100 will pass - and it willonly take values that are FACTORS of 50. So, 100 will pass and101-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 valuefor 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 bebetween 10 and 500<BR></span>
Here is the code that added it:
Public Shared Function AddRangeValidator(ByVal ColNumber AsInteger, ByVal ColName As String, ByVal pl_hold As PlaceHolder,Optional ByVal minvalue As Integer = -1, Optional ByVal maxvalueAs 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
Is this a bug in .NET?
Here is the HTML except from the page:
<span id="_ctl3" controltovalidate="t_7" errormessage="The valuefor 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 bebetween 10 and 500<BR></span>
Here is the code that added it:
Public Shared Function AddRangeValidator(ByVal ColNumber AsInteger, ByVal ColName As String, ByVal pl_hold As PlaceHolder,Optional ByVal minvalue As Integer = -1, Optional ByVal maxvalueAs 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