Home > Articles

  • Print
  • + Share This
This chapter is from the book

Q&A

  1. Do I have to validate on the server side as well as the client side?

  1. No, you don't need to test for validity on the server once a form is submitted. Often, client-side validation will succeed in forcing all the correct user input. However, there are times when it pays to be safe, especially because the client-side validation relies on JavaScript, which has different mechanisms than ASP.NET.

  1. The dynamic error messages aren't being displayed. What's wrong?

  1. Be sure that you've tried to submit the form at least once. The error messages will appear after the first attempt to submit (that is, if the input is invalid). After the first post, the dynamic messages should appear and disappear automatically when you move through the UI elements.

  2. Also, make sure that you're using a newer browser version that supports DHTML (IE or Netscape 4+).

  1. When should I use Validation controls?

  1. Whenever you need to! Validating input is a must for any serious application, and the Validation controls make it very easy in ASP.NET.

  2. That said, Validation controls do add some overhead to your pages, increasing file sizes. Since increased file sizes take longer to send back and forth with the server, your users may notice a slight decrease in performance. Also, to get the full benefit of the Validation controls, the client must support JavaScript and DHTML.

    If you're in a performance-critical situation where bandwidth is a precious commodity, or if you know that you'll have clients with older browsers, it may be wise to stick with the traditional form of validation. That is, stick with if and case statements on the server.

  • + Share This
  • 🔖 Save To Your Account