p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning ASP.NET 4.5 : in C# and VB (http://p2p.wrox.com/forumdisplay.php?f=710)
-   -   Ch 9 Custom Validator - client vs. server (http://p2p.wrox.com/showthread.php?t=92045)

AlanWheeler January 26th, 2014 06:33 PM

Ch 9 Input Validation - client vs. server
Hi Imar,

Since my post on Jan 24 last Friday I've made it to Ch 9 which I'm still wrapping up.

As I was playing around with the project I set a breakpoint in ContactForm.ascx.vb on the 'If' statement for the CustomValidator1_ServerValidate method that handles the server side validation. I don't remember why I did that, but the result seemed pretty neat.

Every time I tried to 'send' the email with a violation of the rules, the breakpoint was not executed. I think that nicely shows the client side validation is really occurring at the client. When the data is finally setup correctly and the 'send' is clicked, the breakpoint executes showing that the server side validation for the phone numbers goes into action. I decided to try it in and saw a similar effect with a breakpoint in the Page_Load method of the Frontend.master.vb file.

Even though I stumbled on it, it seemed like a pretty neat demo to me. Hopefully this doesn't come across as presumptuous, but I didn't know if it would be useful in whatever version of the book comes next. I just thought I should share it with you now; unless of course I'm misunderstanding what's happening here.

Best Regards, (or Cheers)

Imar January 27th, 2014 07:30 AM

Hi Alan,

Yes, this makes perfect sense. The code doesn't fire at the server until all your client side validation has passed. You could disable JavaScript in the browser and you would see that the server side functionality does fire immediately.

Debugging is only discussed in Chapter 18, so it's not something that can easily be explained in Chapter 9. However, the debugging chapter has some demos that show you end to end debugging from client side code into a server side web service, so hopefully you find that demo interesting as well.

Thanks for your suggestion.



All times are GMT -4. The time now is 09:30 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.