CustomValidator bug?

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default CustomValidator bug?

    Hi.

    I am fighting the CustomValidator strange behavior for second day already.
    I created some test project which is only to reproduce the problem.

    1. I created UserControl which has an only a Custom Validator
    2. in UserControl::Page_Load i set
    CustomValidator1.IsValid = false;

    3. I insert the User Control into the page and have a submit button there.


    So when i run the project it shows me errors from CustomValidator (because
    IsValid set to false)
    But when i click submit button there is no error shown and Page.IsValid
    returns true.


    Am i missing something? Where should i set CustomValidator1.IsValid = false;
    so the Page.IsValid would be set to false as well?


    Thanks.
    George.


    George Ter-Saakov Guest

  2. Similar Questions and Discussions

    1. customValidator in DATAGRID
      hi everyone, i' ve got a datagrid in which there is a column with an input texbox in the column "template", i've added a customvalidator an one...
    2. CustomValidator and XMLHTTPRequest
      yes. "Anatoly" <anatolyr@gilat.com> wrote in message news:#feBwBqVDHA.2248@TK2MSFTNGP10.phx.gbl...
    3. CustomValidator controls
      I have a User Control which has one CustomValidator control. In debug I can see that validation is failing in UserControl::Page_Load and IsValid...
    4. CustomValidator limitation?
      I have one CustomValidator that compares 2 password fields together, and the other that checks for a contact method and its correspoding details...
    5. Errormessage in CustomValidator
      Hi, I´m using a server function in a CustomValidator control to verify a field date content before an insert process. What should I do to avoid...
  3. #2

    Default Re: CustomValidator bug?


    "George Ter-Saakov" <we@hotmail.com> wrote in message
    news:ugr99JFUDHA.1552@TK2MSFTNGP10.phx.gbl...
    > Hi.
    >
    > I am fighting the CustomValidator strange behavior for second day already.
    > I created some test project which is only to reproduce the problem.
    >
    > 1. I created UserControl which has an only a Custom Validator
    > 2. in UserControl::Page_Load i set
    > CustomValidator1.IsValid = false;
    >
    > 3. I insert the User Control into the page and have a submit button there.
    >
    >
    > So when i run the project it shows me errors from CustomValidator (because
    > IsValid set to false)
    > But when i click submit button there is no error shown and Page.IsValid
    > returns true.
    >
    >
    > Am i missing something? Where should i set CustomValidator1.IsValid =
    false;
    > so the Page.IsValid would be set to false as well?
    >
    >
    > Thanks.
    > George.
    >
    >
    To implement a CustomValidator you need to handle the ServerValidate event.


    private void CustomValidator1_ServerValidate(object source,
    System.Web.UI.WebControls.ServerValidateEventArgs args)
    {
    args.IsValid = false;
    }


    Hans Kesting


    Hans Kesting Guest

  4. #3

    Default Re: CustomValidator bug?

    Got to the bottom of it.
    It turned out that I must provide handler CustomValidator.ServerValidate and
    set args.IsValid = false in it.

    Otherwise the IsValid is reset to true.

    Which is not very good design. I would say if ServerValidate event is not
    handled then IsValid must stay as is.

    Thanks.
    George.


    "George Ter-Saakov" <we@hotmail.com> wrote in message
    news:ugr99JFUDHA.1552@TK2MSFTNGP10.phx.gbl...
    > Hi.
    >
    > I am fighting the CustomValidator strange behavior for second day already.
    > I created some test project which is only to reproduce the problem.
    >
    > 1. I created UserControl which has an only a Custom Validator
    > 2. in UserControl::Page_Load i set
    > CustomValidator1.IsValid = false;
    >
    > 3. I insert the User Control into the page and have a submit button there.
    >
    >
    > So when i run the project it shows me errors from CustomValidator (because
    > IsValid set to false)
    > But when i click submit button there is no error shown and Page.IsValid
    > returns true.
    >
    >
    > Am i missing something? Where should i set CustomValidator1.IsValid =
    false;
    > so the Page.IsValid would be set to false as well?
    >
    >
    > Thanks.
    > George.
    >
    >

    George Ter-Saakov Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139