Custom Validation Summary Problem

Discussion in 'ASP .Net' started by kpg, Dec 15, 2006.

  1. kpg

    kpg Guest

    I can't get the CustomValidator (CV) ErrorMessage to display
    in the ValidationSummary.

    On the same page I have several RequiredField Validators
    and a Range Validator, that all work just fine, that is,
    the ErrorMessage text is displayed by the Validation summary
    control.

    If I leave the CV Text field blank then the errormmessage
    does display on the CV itself.

    According to the MSDN help, the Validation summary control
    should display the messages of all validator controls
    on the page.

    Is this a bug or am I doing something wrong?

    kpg
     
    kpg, Dec 15, 2006
    #1
    1. Advertising

  2. kpg

    bruce barker Guest

    the validation summary only updates its display when a submit is attempted.

    -- bruce (sqlwork.com)

    kpg wrote:
    > I can't get the CustomValidator (CV) ErrorMessage to display
    > in the ValidationSummary.
    >
    > On the same page I have several RequiredField Validators
    > and a Range Validator, that all work just fine, that is,
    > the ErrorMessage text is displayed by the Validation summary
    > control.
    >
    > If I leave the CV Text field blank then the errormmessage
    > does display on the CV itself.
    >
    > According to the MSDN help, the Validation summary control
    > should display the messages of all validator controls
    > on the page.
    >
    > Is this a bug or am I doing something wrong?
    >
    > kpg
     
    bruce barker, Dec 15, 2006
    #2
    1. Advertising

  3. kpg

    kpg Guest

    bruce barker <> wrote in
    news:ewSn#$:

    > the validation summary only updates its display when a submit is
    > attempted.


    I have a submit button with validation set to true, when
    clicked, the other vaidation control's error messages are
    displayed in the validation control. Everything is set up
    properly, but the custom validator's errormessage does not
    display in the validation summary message box.

    kpg
     
    kpg, Dec 15, 2006
    #3
  4. kpg

    Andy Guest

    There are several things you need to ensure to have a customValidator
    work.

    1) The customValidator has to appear in the same container as the field
    being validated

    2) Even if you aren't using client-side validation, you still have to
    specify an empty error checking function in the JScript of the HTML
    page on which the validator resides. And, this "dummy" function has to
    return true for its args (make sure you specify the name of this
    function in the property list for the validator)

    function customvalidator(source,args){
    args.IsValid=true;
    }

    3) In the server-side custom validation code, you have to set three
    properties on your validator if the check failed for the message to
    appear in the summary control, and your server-side custom validation
    code has to return false for edit failures:


    private function yourCustomCheckingRoutine()
    System.Boolean blnResult=true;

    if(yourTest)
    {
    blnResult=false;
    cvYourValidator.ErrorMessage="Your error message";
    cvYourValidator.Text="*";
    cvYourValidator.IsValid=false;
    }

    return(blnResult);
    }
     
    Andy, Dec 15, 2006
    #4
  5. kpg

    kpg Guest

    "Andy" <> wrote in
    news::

    > 2) Even if you aren't using client-side validation, you still have to
    > specify an empty error checking function in the JScript of the HTML
    > page on which the validator resides. And, this "dummy" function has to
    > return true for its args (make sure you specify the name of this
    > function in the property list for the validator)



    This was it. Once I added the dummy function it worked.

    This must be a bug, the documentation says the client side script
    is optional.

    Thanks
    kpg
     
    kpg, Dec 15, 2006
    #5
    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,695
    Colin Mackay
    Jun 25, 2003
  2. Libs
    Replies:
    0
    Views:
    1,498
  3. Lucas Tam
    Replies:
    2
    Views:
    1,114
    Lucas Tam
    Feb 26, 2004
  4. =?Utf-8?B?QmFyYmFyYSBBbGRlcnRvbg==?=

    Using Summary Validation control with server Custom validation

    =?Utf-8?B?QmFyYmFyYSBBbGRlcnRvbg==?=, Oct 15, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    883
    =?Utf-8?B?QmFyYmFyYSBBbGRlcnRvbg==?=
    Oct 15, 2004
  5. Replies:
    1
    Views:
    3,789
    bruce barker
    Dec 12, 2008
Loading...

Share This Page