Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Building Controls / October 2006

Tip: Looking for answers? Try searching our database.

Suppress ServerValidate on Page?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
philaphan80@yahoo.com - 23 Oct 2006 21:39 GMT
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 - 27 Oct 2006 18:23 GMT
Wow, did I stump the group or did I simply confuse everyone with my
explanation of the problem?  lol

Bueller?  Bueller?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.