Sams Teach Yourself ASP.NET in 21 Days, Second Edition
By Chris Payne
Table of Contents
Day 7.  Validating ASP.NET Pages



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


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.


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


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.

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


When should I use Validation controls?


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

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.


    Sams Teach Yourself ASP. NET in 21 Days
    Sams Teach Yourself ASP.NET in 21 Days (2nd Edition)
    ISBN: 0672324458
    EAN: 2147483647
    Year: 2003
    Pages: 307
    Authors: Chris Payne

    Similar book on Amazon © 2008-2017.
    If you may any questions please contact us: