Suppress ServerValidate on Page?

Discussion in 'ASP .Net Web Controls' started by philaphan80@yahoo.com, Oct 30, 2006.

  1. Guest

    (Tried this in another group with no response........)

    This may or may not be possible, so please let me know either way. I'm
    just attempting to do something fancy and I haven't been able to find
    any documentation on this specific issue anywhere.

    I have a custom validator which runs only on the server side. It
    "attaches" itself to a label to display one error message at a time.
    So, if multiple validation controls fail, it only displays the first
    one in line. Once corrected, it will display the second one. And so
    on.

    So far, it's working well both alone and in multiple instances.

    Because it's designed to only display one message, allowing the page to
    validate the other controls is overkill.

    What I'd like to do is skip the other validators if one of them fails.
    At this point, I'm able to trap and exit the validation within the
    custom control's ServerValidate function, but I'm having a problem
    skipping it on the page itself. If the ServerValidate function is
    added to the Page, it runs even if it's been told to exit from within
    the custom control.

    Is there a command (or workaround) that will allow me to override or
    exit the event in the page's code-behind from within the custom
    control?


    [Custom Control]

    Private Sub CustomServerValidator_ServerValidate(ByVal source As
    Object, ByVal args As
    System.Web.UI.WebControls.ServerValidateEventArgs) Handles
    Me.ServerValidate

    For Each item As CustomServerValidator In Page.Validators

    If Not item.IsValid Then

    Exit Sub

    End If

    Next

    If Me.ValidateEmptyText AndAlso args.Value = "" Then

    args.IsValid = False
    CType(Page.FindControl(Me.ErrorLabel), Label).Text =
    Me.ErrorMessage

    End If

    End Sub

    End Class


    [Page]

    Protected Sub CustomServerValidator1_ServerValidate(ByVal source As

    Object, ByVal args As
    System.Web.UI.WebControls.ServerValidateEventArgs) Handles
    CustomServerValidator1.ServerValidate

    MsgBox("I ran anyway!")

    End Sub

    Protected Sub CustomServerValidator2_ServerValidate(ByVal source As

    Object, ByVal args As
    System.Web.UI.WebControls.ServerValidateEventArgs) Handles
    CustomServerValidator2.ServerValidate

    MsgBox("I ran anyway!")

    End Sub
     
    , Oct 30, 2006
    #1
    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. bruce barker
    Replies:
    1
    Views:
    614
    z. f.
    Aug 3, 2004
  2. headware
    Replies:
    2
    Views:
    620
    headware
    Mar 9, 2005
  3. =?Utf-8?B?RGF2ZQ==?=

    attaching an event to ServerValidate

    =?Utf-8?B?RGF2ZQ==?=, May 15, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    429
    =?Utf-8?B?S2VpdGg=?=
    May 15, 2007
  4. Aamir Ghanchi
    Replies:
    1
    Views:
    512
    Aamir Ghanchi
    Oct 2, 2007
  5. Suppress ServerValidate on Page?

    , Oct 23, 2006, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    123
Loading...

Share This Page