BaseValidator Inherited Ctrl Not working with RequiredFieldValidator

Discussion in 'ASP .Net Building Controls' started by James, Oct 17, 2005.

  1. James

    James Guest

    Hi All,

    I have written a control that inherits BaseValidator. If it used by
    itself on a page, the control works perfectly fine.

    If I drop the RequiredFieldValidator on the same page to evaluate a
    different textbox, my control does not work. But *only* if
    RequiredFieldValidator does not pass.

    It seems like when RequiredFieldValidator raises False, it shuts
    everything else off.

    I placed a breakpoint in my control, and it doesn't even go into it.

    Any suggestions are greatly appreciated!

    Thanks!!
    James
    James, Oct 17, 2005
    #1
    1. Advertising

  2. James

    James Guest

    Well, after I placed this post, I tried changing "Enable Client Script"
    to FALSE on the RequiredFieldValidator control.

    This allowed my control to work properly!

    I'm not using client side scripting, so this not an issue. But it
    would seem strange that this would have to be the case.

    Perhaps somebody could explain why this would need to be done?

    Thanks!
    James
    James, Oct 17, 2005
    #2
    1. Advertising

  3. James

    Teemu Keiski Guest

    Hi,

    at client if RequiredFieldValidator fails, that already prevents the page
    from posting back (since one of the validators indicates error).

    It is so that if your control has no input/selection whatsoever,
    RequiredFieldValidator is the one catching that, and no other validators
    will be yet invoked (e.g by default no other validator than RFV is applied
    for empty input). Then if there is some input, RFV will pass validation, and
    other, more specialized validators kick in, like check the correctness of
    the given input, as the input now exists.

    Mechanically it happens so that if validation control is passed empty input
    value, it returns true as outcome of the validation. This way, it's left up
    to the RFV in the first place to check for empty inputs.

    You can tweak this behaviour with custom validators / 3rd party validator
    controls & components (Professional Validation And More for instance)

    --
    Teemu Keiski
    ASP.NET MVP, AspInsider
    Finland, EU
    http://blogs.aspadvice.com/joteke


    "James" <> wrote in message
    news:...
    > Well, after I placed this post, I tried changing "Enable Client Script"
    > to FALSE on the RequiredFieldValidator control.
    >
    > This allowed my control to work properly!
    >
    > I'm not using client side scripting, so this not an issue. But it
    > would seem strange that this would have to be the case.
    >
    > Perhaps somebody could explain why this would need to be done?
    >
    > Thanks!
    > James
    >
    Teemu Keiski, Dec 4, 2005
    #3
    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. Danny

    Implement Ctrl-C, Ctrl-V

    Danny, Aug 14, 2003, in forum: C++
    Replies:
    5
    Views:
    639
    CBFalconer
    Aug 15, 2003
  2. Danny

    Implement Ctrl-C, Ctrl-V

    Danny, Aug 14, 2003, in forum: C Programming
    Replies:
    5
    Views:
    651
    CBFalconer
    Aug 15, 2003
  3. Angus
    Replies:
    5
    Views:
    2,088
    Michael Rauscher
    Nov 18, 2006
  4. Replies:
    2
    Views:
    1,399
    Munna
    Jul 10, 2008
  5. Replies:
    0
    Views:
    551
Loading...

Share This Page