CompareValidator not working where a RangeValidator is

Discussion in 'ASP .Net' started by hooterbite, Mar 28, 2005.

  1. hooterbite

    hooterbite Guest

    The range validator works, the compare validator doesn't.

    Dim txbNew As New TextBox
    txbNew.ID = "txb" & arStyles(i)

    Dim rvNew As New RangeValidator
    rvNew.Text = "Must be a number greater then 0"
    rvNew.ControlToValidate = "txb" & arStyles(i)
    rvNew.EnableClientScript = False
    rvNew.MinimumValue = 1
    rvNew.MaximumValue = 1000

    Dim cvNew As New CompareValidator
    cvNew.Text = "Must be a number greater then 0"
    cvNew.ControlToValidate = "txb" & arStyles(i)
    cvNew.EnableClientScript = False
    cvNew.Operator = ValidationCompareOperator.DataTypeCheck
    cvNew.Type = ValidationDataType.Integer

    hooterbite, Mar 28, 2005
    1. Advertisements

  2. hooterbite

    Brock Allen Guest

    Set the validator's Type to be ValidationDataType.Integer (or Double).
    Brock Allen, Mar 28, 2005
    1. Advertisements

  3. hooterbite

    hooterbite Guest

    Thanks Brock, if you looked at the code you would see that it is there
    - cvNew.Type = ValidationDataType.Integer
    hooterbite, Mar 29, 2005
  4. hooterbite

    Brock Allen Guest

    But rvNew does not. Type in 01 into the range validator and see if it still
    Brock Allen, Mar 29, 2005
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.