CustomValidator Control

Discussion in 'ASP .Net' started by =?Utf-8?B?Vmk=?=, Oct 21, 2004.

  1. Hi,
    I have a TextBox, Button and CustomValidator web controls on an aspx page.
    When a user clicks the Button, I want to perform server side validation of
    the textbox with the method specified in the CustomValidator control.
    When the validation fails, I'm setting the args.IsValid=false; so it will
    display the message on the page, but the application does not stop and
    continues and executes the Button click EventHandler.
    How can I stop the execution of the page after the validation fails?
    Thank you.
     
    =?Utf-8?B?Vmk=?=, Oct 21, 2004
    #1
    1. Advertising

  2. =?Utf-8?B?Vmk=?=

    Scott Allen Guest

    It's one of those unfortunate quirks that client side validation will
    stop a client's POST operation dead in it's tracks, but server side
    validation requires your code to explicitly check Page.IsValid and
    branch away from the typical flow of execution.

    In other words, you probably want to wrap your logic in the button
    click event with:

    if(Page.IsValid)
    {

    }

    --
    Scott
    http://www.OdeToCode.com/blogs/scott/

    On Wed, 20 Oct 2004 20:55:01 -0700, "Vi"
    <> wrote:

    >Hi,
    >I have a TextBox, Button and CustomValidator web controls on an aspx page.
    >When a user clicks the Button, I want to perform server side validation of
    >the textbox with the method specified in the CustomValidator control.
    >When the validation fails, I'm setting the args.IsValid=false; so it will
    >display the message on the page, but the application do not stop and
    >continues and executes the Button click EventHandler.
    >How can I stop the execution of the page after the validation fails?
    >Thank you.
     
    Scott Allen, Oct 21, 2004
    #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. Jim Heavey

    CustomValidator Control

    Jim Heavey, Dec 2, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    352
  2. Dan Sikorsky
    Replies:
    1
    Views:
    5,874
    Dan Sikorsky
    Feb 17, 2005
  3. avp
    Replies:
    1
    Views:
    21,683
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
    Dec 16, 2005
  4. Replies:
    1
    Views:
    393
    Brennan Stehling
    Oct 26, 2006
  5. Arti
    Replies:
    0
    Views:
    332
Loading...

Share This Page