ASP.NET
  Home arrow ASP.NET arrow Page 2 - Input Validation With ASP.NET, Part 1
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP.NET

Input Validation With ASP.NET, Part 1
By: Harish Kamath (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 35
    2004-02-16

    Table of Contents:
  • Input Validation With ASP.NET, Part 1
  • Making Friends
  • First Glance
  • If Looks Could Kill
  • Pizza Power
  • A Comparative Study

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Input Validation With ASP.NET, Part 1 - Making Friends


    (Page 2 of 6 )

    It is a common practice to use client-side scripting languages like JavaScript or VBScript for client side input validation. However, this type of client-side validation is not foolproof. Remember, you're not in control of the client, so if a user turns off JavaScript in his or her browser, all your efforts to ensure that the user does not enter irrelevant data will become... well, irrelevant. That's why most experienced developers use both client-side and server-side validation. Server-side validation involves checking the values submitted to the server through a server-side script, and taking appropriate action when the input is incorrect.

    That's where the ASP.NET Validator controls come in. In a Web-based application, each Validator control (there are five of them in all, and I've covered them all in this tutorial) is linked to a form control. When a user submits a form, the .NET framework ensures that the data entered by the user is filtered through the Validators, and checked for accuracy. If any of the values flunk the validation tests, an exception is generated; this can then be caught and resolved by the application's exception-handling mechanisms.

    With ASP.NET's Validators, it's also possible to perform selective validation, wherein one validation test is dependent on the results of another. For example, if the user states that she's living in the US, you might also require him or her to enter a US state code. However, if the user indicates that she's living outside the US, it doesn't make sense to ask for a state code.

    So which kinds of validations are possible using these ASP.NET Validator controls? Here's a quick list:

    RequiredFieldValidator - forces entry of a value for the associated control

    CompareValidator - used with a comparison operator to compare the value provided against a constant value or another control

    RangeValidator - checks whether the value entered is within a specified range

    RegularExpressionValidator - uses regular expressions to validate user input

    CustomValidator - allows you to create customized validation routines

    More ASP.NET Articles
    More By Harish Kamath (c) Melonfire


     

    ASP.NET ARTICLES

    - Disadvantages of the ASP.NET MVC Framework
    - Advantages of the ASP.NET MVC Approach
    - ASP.NET Web Forms Weaknesses
    - ASP.NET Web Forms Meets ASP.NET MVC
    - Source Code for Saving and Retrieving Data w...
    - Using GridView to Save and Retrieve Data wit...
    - Handling Dynamic Images in ASP.NET 3.5 AJAX ...
    - Retrieving Data with AJAX and the GridView C...
    - Playing with Images in ASP.NET 3.5 AJAX Appl...
    - Saving and Retrieving Data with AJAX
    - Enhancing PHP Via the ASP.NET AJAX Framework...
    - Enhancing PHP Programming with the ASP.NET A...
    - Classes and ASP.NET AJAX
    - Using ASP.NET AJAX
    - Building a Simple Storefront with LINQ





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
    Stay green...Green IT