SlideServe
Menu
Préférences
© SlideServe · v2026

Comprehensive Guide to ASP.NET User Input Validation: Client-Side and Server-Side Techniques

aileen avatar
9 diapositives · 239 Views · Oct 09, 2014

Dive into the essentials of user input validation in ASP.NET, focusing on both client-side and server-side approaches. Learn how to effectively check for data validity from end users by utilizing various validation techniques, including RequiredFieldValidator, CompareValidator, RangeValidator, and RegularExpressionValidator. Discover best practices for implementing validation, the impact of JavaScript support, and the importance of server-side validation for enhanced security. Reinforce your ASP.NET applications with reliable input validation methods.

Comprehensive Guide to ASP.NET User Input Validation: Client-Side and Server-Side Techniques - slide 1
01 / 9Comprehensive Guide to ASP.NET User Input Validation: Client-Side and Server-Side Techniques
1 / 17

Télécharger la présentation

Comprehensive Guide to ASP.NET User Input Validation: Client-Side and Server-Side Techniques
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. ASP.NET Validating user input Validating user input on the client and/or server side ASP.NET Validating User Input

  2. Validation • Goals • Check validity of data from the end user • How • Check user input on the client side or on the server side • Examples • Is the name TextBox empty? • Does the email TextBox contain a structurally valid email address? ASP.NET Validating User Input

  3. Client-side validation Done in the browser Uses JavaScript Users can disable JavaScript! Different browsers → different JavaScript versions Does not require HTTP request + response Server-side validation Done on the server Uses C# Requires HTTP request + response Client-side vs. server-side validation ASP.NET Validating User Input

  4. Client-side and server-side validation • Best practice • Client-side validation and server-side validation • Client-side saves time • No HTTP request/response • Server-side • Provides security • JavaScript not disable ASP.NET Validating User Input

  5. ASP.NET Validation server controls • ASP.NET performs browser detection • Client supports JavaScript • Use client-side validation + server-side validation • Client does not support JavaScript • Use server-side validation ASP.NET Validating User Input

  6. The standard validation controls • RequiredFieldValidator • Input field cannot be empty • CompareValidator • Compare between user inputs using =, >, etc. • RangeValidator • Minimum < input < maximum • RegularExpressionValidator • Check the entry matches a pattern defined by the regular expression • CustomValidator • Make your own validator • DynamicValidator • Advanced: Exceptions thrown from the model • ValidationSummary • Displays all error messages from validators in one spot • Third-party controls • Not made by Microsoft or by you • Examples: www.peterblum.com/DES ASP.NET Validating User Input

  7. Some properties common to all validation controls • ControlToValidate • The control to be validated • ErrorMessage • The message used in the ValidationSummary • Text • The error message used in the validation control • CssClass • Style appearance of the messages • Example: aspnet/validation/Validation ASP.NET Validating User Input

  8. Making validation happen – or not • Validation happens because of an event • Example: button click event • Can be turned of (for some buttons in a form) • <asp:Button ID=“Button1” runat=“server” Text=“Submit” CausesValidation=“false” > • Client-side validation can be turned off • Only server-side validation in effect • <asp:RequiredFieldValidator … EnableClientScript=“false”> ASP.NET Validating User Input

  9. References • Bill Evjen et al. Professional ASP.NET 4 in C# and VB, Wrox 2010 • Chapter 4, Validation Server Controls, page 157-185 • W3schools.com Validation Server Controls • http://w3schools.com/aspnet/aspnet_refvalidationcontrols.asp ASP.NET Validating User Input