custom validation

Discussion in 'ASP .Net' started by Tarscher, Feb 6, 2007.

  1. Tarscher

    Tarscher Guest

    Hi all,

    I have a custom validation on server side (I disabled client side).
    The validation is inside a user control but doesn't seem to work. For
    simplifying things I took out almost all code of the function that the
    custom user control calls ( CustomValidator1_ServerValidate) when
    clicking a button

    protected void CustomValidator1_ServerValidate(object source,
    ServerValidateEventArgs args)
    {
    args.IsValid = false;
    }

    When I click a button this function get called first but then goes to
    the function that handles the buttonclick. I don't see why it stops
    and returns an errorstate to the page?

    Am I missing something?

    Regards,
    Stijn
     
    Tarscher, Feb 6, 2007
    #1
    1. Advertising

  2. If you don't use client validation (even if you do) you have to test for the
    Page.IsValid == true on every postback, there fore in your button click event
    handler add following condition .:

    protected void btn_Click(object sender, EventArgs e)
    {
    if (IsValid) // on user / webserver controls use Page.IsValid
    {
    // do what you did before
    }
    }
    --
    Milosz


    "Tarscher" wrote:

    > Hi all,
    >
    > I have a custom validation on server side (I disabled client side).
    > The validation is inside a user control but doesn't seem to work. For
    > simplifying things I took out almost all code of the function that the
    > custom user control calls ( CustomValidator1_ServerValidate) when
    > clicking a button
    >
    > protected void CustomValidator1_ServerValidate(object source,
    > ServerValidateEventArgs args)
    > {
    > args.IsValid = false;
    > }
    >
    > When I click a button this function get called first but then goes to
    > the function that handles the buttonclick. I don't see why it stops
    > and returns an errorstate to the page?
    >
    > Am I missing something?
    >
    > Regards,
    > Stijn
    >
    >
     
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=, Feb 6, 2007
    #2
    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. Colin Basterfield

    Web form validation vs object validation

    Colin Basterfield, Nov 28, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    429
    Tommy
    Nov 29, 2003
  4. Matt
    Replies:
    14
    Views:
    4,107
    Chad Z. Hower aka Kudzu
    Jan 30, 2004
  5. =?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
Loading...

Share This Page