Validation problem

Discussion in 'ASP .Net' started by tshad, Feb 6, 2006.

  1. tshad

    tshad Guest

    I have been having some issues trying to get validation to work. On most of
    my pages, I have no problem.

    But I have a page that has 4 validation objects and none are displaying an
    error message, but I have this code:

    trace.warn("Before Test on Page.IsValid")
    if not Page.IsValid then Exit Sub
    trace.warn("After Test on Page.IsValid")

    And I never get to the the 2nd trace statement.

    How do I find out what it found was not valid?

    Thanks,

    Tom
    tshad, Feb 6, 2006
    #1
    1. Advertising

  2. Are you calling the Page.Validate method before checking for Page.IsValid ?


    --
    Swanand Mokashi
    Microsoft Certified Solution Developer (.NET) - Early Achiever
    Microsoft Certified Application Developer (.NET)

    http://www.swanandmokashi.com/
    http://www.swanandmokashi.com/HomePage/WebServices/
    Home of the Stock Quotes, Quote of the day and Horoscope web services


    "tshad" <> wrote in message
    news:...
    >I have been having some issues trying to get validation to work. On most
    >of my pages, I have no problem.
    >
    > But I have a page that has 4 validation objects and none are displaying an
    > error message, but I have this code:
    >
    > trace.warn("Before Test on Page.IsValid")
    > if not Page.IsValid then Exit Sub
    > trace.warn("After Test on Page.IsValid")
    >
    > And I never get to the the 2nd trace statement.
    >
    > How do I find out what it found was not valid?
    >
    > Thanks,
    >
    > Tom
    >
    Swanand Mokashi, Feb 6, 2006
    #2
    1. Advertising

  3. tshad

    sam Guest

    Set a breakpoint and look at Page.Validators array. You'll be able to
    check the IsValid property and by their error messages you can tell
    which one in failing.
    sam, Feb 6, 2006
    #3
  4. tshad

    tshad Guest

    "Swanand Mokashi" <> wrote in message
    news:...
    > Are you calling the Page.Validate method before checking for Page.IsValid
    > ?


    No.

    I never do on any of my pages.

    I do have 2 ImageButtons on my screen. Both events have the same problem.

    Why on my other pages does it work ok?

    BTW, I did add the Page.Validate:

    trace.warn("Before Test on Page.IsValid")
    Page.Validate()
    if not Page.IsValid then Exit Sub
    trace.warn("After Test on Page.IsValid")

    And it still doesn't show the 2nd trace.warn nor does it show the messages
    from the Validation objects.

    Thanks,

    Tom

    >
    >
    > --
    > Swanand Mokashi
    > Microsoft Certified Solution Developer (.NET) - Early Achiever
    > Microsoft Certified Application Developer (.NET)
    >
    > http://www.swanandmokashi.com/
    > http://www.swanandmokashi.com/HomePage/WebServices/
    > Home of the Stock Quotes, Quote of the day and Horoscope web services
    >
    >
    > "tshad" <> wrote in message
    > news:...
    >>I have been having some issues trying to get validation to work. On most
    >>of my pages, I have no problem.
    >>
    >> But I have a page that has 4 validation objects and none are displaying
    >> an error message, but I have this code:
    >>
    >> trace.warn("Before Test on Page.IsValid")
    >> if not Page.IsValid then Exit Sub
    >> trace.warn("After Test on Page.IsValid")
    >>
    >> And I never get to the the 2nd trace statement.
    >>
    >> How do I find out what it found was not valid?
    >>
    >> Thanks,
    >>
    >> Tom
    >>

    >
    >
    tshad, Feb 6, 2006
    #4
  5. tshad

    tshad Guest

    "sam" <> wrote in message
    news:...
    > Set a breakpoint and look at Page.Validators array. You'll be able to
    > check the IsValid property and by their error messages you can tell
    > which one in failing.


    How would I do that using trace.warn?

    I am using DW and not Visual Studio and one page not code-behind.

    Thanks,

    Tom
    tshad, Feb 6, 2006
    #5
  6. tshad

    tshad Guest

    I found the problem, but not sure why.

    I had a Validation object I had commented out, but the program was still
    seeing it.

    <!--
    <asp:CompareValidator
    ControlToValidate="WagesMin"
    ControlToCompare="WagesMax"
    Operator="LessThanEqual"
    Type="Currency"
    Display="Dynamic"
    Text="<br>Minumum Wage must be less than or equal to the Maximum
    Wage"
    runat="server"/>
    -->

    I didn't realize that the ">" would stop the comment. If this is the case,
    I would have assume there would be an error, or it would just show the rest
    of the asp command on the output page, but it doesn't.

    Why is that?

    Thanks,

    Tom

    "tshad" <> wrote in message
    news:...
    >
    > "Swanand Mokashi" <> wrote in message
    > news:...
    >> Are you calling the Page.Validate method before checking for Page.IsValid
    >> ?

    >
    > No.
    >
    > I never do on any of my pages.
    >
    > I do have 2 ImageButtons on my screen. Both events have the same problem.
    >
    > Why on my other pages does it work ok?
    >
    > BTW, I did add the Page.Validate:
    >
    > trace.warn("Before Test on Page.IsValid")
    > Page.Validate()
    > if not Page.IsValid then Exit Sub
    > trace.warn("After Test on Page.IsValid")
    >
    > And it still doesn't show the 2nd trace.warn nor does it show the messages
    > from the Validation objects.
    >
    > Thanks,
    >
    > Tom
    >
    >>
    >>
    >> --
    >> Swanand Mokashi
    >> Microsoft Certified Solution Developer (.NET) - Early Achiever
    >> Microsoft Certified Application Developer (.NET)
    >>
    >> http://www.swanandmokashi.com/
    >> http://www.swanandmokashi.com/HomePage/WebServices/
    >> Home of the Stock Quotes, Quote of the day and Horoscope web services
    >>
    >>
    >> "tshad" <> wrote in message
    >> news:...
    >>>I have been having some issues trying to get validation to work. On most
    >>>of my pages, I have no problem.
    >>>
    >>> But I have a page that has 4 validation objects and none are displaying
    >>> an error message, but I have this code:
    >>>
    >>> trace.warn("Before Test on Page.IsValid")
    >>> if not Page.IsValid then Exit Sub
    >>> trace.warn("After Test on Page.IsValid")
    >>>
    >>> And I never get to the the 2nd trace statement.
    >>>
    >>> How do I find out what it found was not valid?
    >>>
    >>> Thanks,
    >>>
    >>> Tom
    >>>

    >>
    >>

    >
    >
    tshad, Feb 6, 2006
    #6
  7. tshad

    tshad Guest

    The reason I had commented it out was I could not get the Object to work.

    I tried it as both LessThanEqual and GreaterThanEqual and both gave me
    errors.

    I have the code set as:

    trace.warn("WagesMin = " & WagesMin.Text & " WagesMax = " & WagesMax.Text)
    trace.warn("Before Test on Page.IsValid")
    Page.Validate()
    if not Page.IsValid then Exit Sub
    trace.warn("After Test on Page.IsValid")

    and the 1st trace gives me:

    WagesMin = $150.00 WagesMax = $300.00

    MS says that Currency is a decimal field with currency symbols, which I have
    here.

    So why doesn't it work?

    Thanks,

    Tom

    "tshad" <> wrote in message
    news:...
    >I found the problem, but not sure why.
    >
    > I had a Validation object I had commented out, but the program was still
    > seeing it.
    >
    > <!--
    > <asp:CompareValidator
    > ControlToValidate="WagesMin"
    > ControlToCompare="WagesMax"
    > Operator="LessThanEqual"
    > Type="Currency"
    > Display="Dynamic"
    > Text="<br>Minumum Wage must be less than or equal to the Maximum
    > Wage"
    > runat="server"/>
    > -->
    >
    > I didn't realize that the ">" would stop the comment. If this is the
    > case, I would have assume there would be an error, or it would just show
    > the rest of the asp command on the output page, but it doesn't.
    >
    > Why is that?
    >
    > Thanks,
    >
    > Tom
    >
    > "tshad" <> wrote in message
    > news:...
    >>
    >> "Swanand Mokashi" <> wrote in message
    >> news:...
    >>> Are you calling the Page.Validate method before checking for
    >>> Page.IsValid ?

    >>
    >> No.
    >>
    >> I never do on any of my pages.
    >>
    >> I do have 2 ImageButtons on my screen. Both events have the same
    >> problem.
    >>
    >> Why on my other pages does it work ok?
    >>
    >> BTW, I did add the Page.Validate:
    >>
    >> trace.warn("Before Test on Page.IsValid")
    >> Page.Validate()
    >> if not Page.IsValid then Exit Sub
    >> trace.warn("After Test on Page.IsValid")
    >>
    >> And it still doesn't show the 2nd trace.warn nor does it show the
    >> messages from the Validation objects.
    >>
    >> Thanks,
    >>
    >> Tom
    >>
    >>>
    >>>
    >>> --
    >>> Swanand Mokashi
    >>> Microsoft Certified Solution Developer (.NET) - Early Achiever
    >>> Microsoft Certified Application Developer (.NET)
    >>>
    >>> http://www.swanandmokashi.com/
    >>> http://www.swanandmokashi.com/HomePage/WebServices/
    >>> Home of the Stock Quotes, Quote of the day and Horoscope web services
    >>>
    >>>
    >>> "tshad" <> wrote in message
    >>> news:...
    >>>>I have been having some issues trying to get validation to work. On
    >>>>most of my pages, I have no problem.
    >>>>
    >>>> But I have a page that has 4 validation objects and none are displaying
    >>>> an error message, but I have this code:
    >>>>
    >>>> trace.warn("Before Test on Page.IsValid")
    >>>> if not Page.IsValid then Exit Sub
    >>>> trace.warn("After Test on Page.IsValid")
    >>>>
    >>>> And I never get to the the 2nd trace statement.
    >>>>
    >>>> How do I find out what it found was not valid?
    >>>>
    >>>> Thanks,
    >>>>
    >>>> Tom
    >>>>
    >>>
    >>>

    >>
    >>

    >
    >
    tshad, Feb 6, 2006
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Colin Mackay
    Replies:
    0
    Views:
    2,684
    Colin Mackay
    Jun 25, 2003
  2. Libs
    Replies:
    0
    Views:
    1,490
  3. Colin Basterfield

    Web form validation vs object validation

    Colin Basterfield, Nov 28, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    425
    Tommy
    Nov 29, 2003
  4. Matt
    Replies:
    14
    Views:
    4,093
    Chad Z. Hower aka Kudzu
    Jan 30, 2004
  5. bnp
    Replies:
    4
    Views:
    318
Loading...

Share This Page