Suppress ServerValidate on Page?

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

  1. #1

    Default Suppress ServerValidate on Page?

    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

    philaphan80@yahoo.com Guest

  2. Similar Questions and Discussions

    1. Suppress printing of links in a pdf
      Is it possible to make regions/specific text of a pdf page invisible when it prints out? I have a document with links to different pages but I don't...
    2. Suppress entire layer?
      InDesign CS (Mac) running under 10.4.7 In InDesign Is there a way to suppress (make nonprinting) an entire layer, in the same fashion as...
    3. Suppress the DB warnings
      Hi there, Using DBI in my Programm, i get all the warnings on the screen (which is not desired) , though i have set $dbh->{PrintError} = 0; ...
    4. [PHP] Suppress errors when running as CGI?
      On Thu, Aug 07, 2003 at 01:22:21PM -0500, Chris Boget wrote: Uh, no... plus, then I'd have to know about errors ahead of time. If I _knew_...
    5. suppress toolbars at runtime install?
      Hi, I am building a runtime solution, but I want to suppress the toolbars and statusbar (Windows) at installation. On my Mac i can install a...
  3. #2

    Default Re: Suppress ServerValidate on Page?

    Wow, did I stump the group or did I simply confuse everyone with my
    explanation of the problem? lol

    Bueller? Bueller?

    philaphan80@yahoo.com 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