Asp.NET Core Vaidation Controls. Slide 2 ASP.NET Validation Controls (Introduction) The ASP.NET validation controls can be used to validate data on the.

Slides:



Advertisements
Similar presentations
JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
Advertisements

CSCI 6962: Server-side Design and Programming Input Validation and Error Handling.
Regular Expressions in Perl By Josue Vazquez. What are Regular Expressions? A template that either matches or doesn’t match a given string. Often called.
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
The Web Warrior Guide to Web Design Technologies
Microsoft VB 2005: Reloaded, Advanced Chapter 5 Input Validation, Error Handling, and Exception Handling.
Regular Expression Original Notes by Song Guo. What Regular Expressions Are Exactly - Terminology a regular expression is a pattern describing a certain.
CS 898N – Advanced World Wide Web Technologies Lecture 8: PERL Chin-Chih Chang
VBA Modules, Functions, Variables, and Constants
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
LING 388: Language and Computers Sandiway Fong Lecture 3: 8/28.
JavaScript, Third Edition
ASP.NET Validating user input Validating user input on the client and/or server side 1ASP.NET Validating User Input.
Scripting Languages Chapter 8 More About Regular Expressions.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
Chapter Seven Advanced Shell Programming. 2 Lesson A Developing a Fully Featured Program.
Chapter 9 – Validating User Input Dr. Stephanos Mavromoustakos.
XP Tutorial 14 New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
Last Updated March 2006 Slide 1 Regular Expressions.
CIS 375—Web App Dev II ASP.NET 2 Introducing Web Forms.
Database-Driven Web Sites, Second Edition1 Chapter 8 Processing ASP.NET Web Forms and Working With Server Controls.
Module 7: Validating User Input.
.NET Validation Controls MacDonald Ch. 8 MIS 324 MIS 324 Professor Sandvig Professor Sandvig.
Chapter 3 Using Validation Controls. What is a Validation Control? A control that validates the value in another control Renders as an HTML tag with an.
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
Telerik Software Academy ASP.NET Web Forms Data Validation, Data Validators, Validation Groups Telerik Software Academy
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
Regular Expression Darby Tien-Hao Chang (a.k.a. dirty) Department of Electrical Engineering, National Cheng Kung University.
 Text Manipulation and Data Collection. General Programming Practice Find a string within a text Find a string ‘man’ from a ‘A successful man’
Regular Expressions in.NET Ashraya R. Mathur CS NET Security.
1 ASP.NET ASP.NET Rina Zviel-Girshin Lecture 3. 2 Overview Cookies Validation controls Client and server side validation Validation control examples.
Web Application and Development Digital Media Department Unit Credit Value : 4 Essential Learning time : 120 hours Digital Media.
BIT 285: ( Web) Application Programming Lecture 08: Thursday, January 29, 2015 Data Validation, Using Validators Instructor: Craig Duckett.
Validation and Rich controls 1www.tech.findforinfo.com.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
ASP.NET Programming with C# and SQL Server First Edition Chapter 5 Manipulating Strings with C#
Microsoft Visual Basic 2005 CHAPTER 7 Creating Web Applications.
RegExp. Regular Expression A regular expression is a certain way to describe a pattern of characters. Pattern-matching or keyword search. Regular expressions.
Using Client-Side Scripts to Enhance Web Applications 1.
Regular Expressions Regular expressions are a language for string patterns. RegEx is integral to many programming languages:  Perl  Python  Javascript.
JavaScript Syntax and Semantics. Slide 2 Lecture Overview Core JavaScript Syntax (I will not review every nuance of the language)
When you read a sentence, your mind breaks it into tokens—individual words and punctuation marks that convey meaning. Compilers also perform tokenization.
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company ASP.NET Validation Control Presented By : Muhammad Atif Hussain Deputy.
VALIDATION CONTROLS.  Validation Controls are primarily used to validate, or verify the data entered by user into a web form.  Validation controls attempt.
HTML Forms. Slide 2 Forms (Introduction) The purpose of input forms Organizing forms with a and Using different element types to get user input A brief.
Chapter 5: Making Decisions. Objectives Plan decision-making logic Make decisions with the if and if…else structures Use multiple statements in if and.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Session 6: Validating User Input. Outline Overview of User Input Validation Client-Side and Server-Side Validation ASP.NET Validation Controls Using Validation.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 User Input Validating.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
Validation using Regular Expressions. Regular Expression Instead of asking if user input has some particular value, sometimes you want to know if it follows.
Vijayalakshmi G M Validation Controls.
CST336, Dr. Krzysztof Pietroszek Week 2: PHP. 1.Introduction to PHP 2.Embed PHP code into an HTML web page 3.Generate (output HTML) web page using PHP.
XP Tutorial 7 New Perspectives on JavaScript, Comprehensive 1 Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
CS 106 Introduction to Computer Science I 09 / 10 / 2007 Instructor: Michael Eckmann.
Text INTRODUCTION TO ASP.NET. InterComm Campaign Guidelines CONFIDENTIAL Simply Server side language Simplified page development model Modular, well-factored,
Beginning ASP.NET in C# and VB Chapter 9
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
Validation Controls Assist your users with providing the correct type of input for your application Assist your users with providing the correct type of.
Validation & Rich Controls
Looking for Patterns - Finding them with Regular Expressions
Web Application Web Application are programs that can be executed either on a Web server or in a Web browser. An Online store accessed through a browser.
Chapter 19 PHP Part II Credits: Parts of the slides are based on slides created by textbook authors, P.J. Deitel and H. M. Deitel by Prentice Hall ©
Introduction to Scripting
Variables and Arithmetic Operations
PHP.
Validation using Regular Expressions
.NET Validation Controls
Validation & Rich Controls
Presentation transcript:

Asp.NET Core Vaidation Controls

Slide 2 ASP.NET Validation Controls (Introduction) The ASP.NET validation controls can be used to validate data on the client, the server, or both Client-side validation is performed using automatically generated JavaScript Server-side validation is performed using VB or C# code in the proper event handler Server-side validation is always enabled while client-side validation is optionally enabled

Slide 3 ASP.NET Validation Controls (Introduction) If client-side validation is enabled, we don’t postback until the client ‘thinks’ the values are valid Always validate on the server-side too to thwart those hackers doing a post on their own

Slide 4 ASP.NET Validation Controls (Server Processing Model 1) Validation controls apply their rules and validate a corresponding control Call the Page.Validate() method to force the validation controls to execute This is usually not necessary Test Page.IsValid to determine whether the page has valid data or not

Slide 5 ASP.NET Validation Controls (Server Processing Model 2) Page states Controls are initialized and populated when the page is loaded After the page loads, the controls are validated and the Page.IsValid property is set The Page.Validators property contains results of each control’s validator Each item in the collection implements IValidator

Slide 6 Checking the Validators (Example) Display the validation messages: For Each v In Page.Validators Response.Write(v.ErrorMessage) Next foreach (Ivalidator v in Page.Validators) { Response.Write(v.ErrorMessage) }

Slide 7 ASP.NET Validation Controls (Concepts) Set the ControlToValidate property the control instance that will be validated Set EnableClientScript to enable client- side validation ASP will generate the necessary JavaScript Set the ErrorMessage property to the error message that will appear in the validation control

Slide 8 ASP.NET Validation Controls ( RequiredFieldValidator and RangeValidator ) RequiredFieldValidator checks that a control has a value RangeValidator checks that a controls value is within a valid range Set the MinimumValue and MaximumValue properties to the valid range A control with no valid is considered valid Use with the RequiredFieldValidator to prevent this Set the Type property to define the data type to be stored in the control to validate

Slide 9 ASP.NET Validation Controls ( CompareValidator ) The CompareValidator validates that the values of two other control instances are the same Set the ControlToValidate and ControlToCompare properties Optionally use a RequiredFieldValidator so that empty controls will not be valid

Slide 10 ASP.NET Validation Controls ( CustomValidator ) The CustomValidator control allows you to easily create custom and client script and server event handlers Set the ControlToValidate as usual Set the ClientValidationFunction to the name of the JavaScript function appearing on the client Server-side validation is automatic You must write the code for the ServerValidate event handler

Slide 11 ASP.NET Validation Controls ( CustomValidator ) The client validation function must accept two arguments The first contains the object that fired the event The second contains the event data

Slide 12 ASP.NET Validation Controls ( CustomValidator ) (Example Client) function validateLength(src,args) { if (args.Value.length <=6) { args.IsValid = true; document.title = "true=" + args.Value.length; } else { args.IsValid = false; document.title = "false" + args.Value.length; }

Slide 13 ASP.NET Validation Controls ( RegularExpressionValidator ) It validates another control instance against a regular expression The regular expression is stored in the ValidationExpression property

Slide 14 ASP.NET Validation Controls ( CustomValidator ) (Example Client) Protected Sub CustomValidator1_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventAr gs) Handles CustomValidator1.ServerValidate If args.Value.Length > 6 Then args.IsValid = True Else args.IsValid = False End If End Sub

Slide 15 Regular Expressions (Introduction) Regular expressions are used throughout computer science and programming languages as a means of pattern matching Patterns are matched using a regular expression engine You generally don't run the engine directly Different implementations have different "flavors”

Slide 16 Regular Expressions (Implementations) Some consider Perl 5 as the basis or standard for regular expressions.NET supports regular expressions JavaScript supports regular expression UNIX scripting languages support regular expressions And of course XML supports them

Slide 17 Regular Expressions (Literal Values) The most simple of regular expressions will match a literal value By default, regular expressions are case sensitive The regular expression "cat" contains three literal characters It will match the following patterns "concatenate" "the cat ran away"

Slide 18 Regular Expressions (Quantifiers) Quantifiers denote how many times a character or pattern can repeat Quantifiers (list) * (0 or more) + (1 or more) ? (0 or 1)

Slide 19 Quantifiers (Example) 1?5? 1 can appear 0-1 times and 5 can appear 0-1 times This pattern also matches an empty string because 1 or 5 can appear 0 times

Slide 20 Quantifiers (Numeric Range) Quantifiers allow us to specify how many times a pattern can occur Numeric range quantifiers appear in curly braces {n} Must occur exactly n times {n,m} Must occur between n and m times {n,} Must occur n or greater times

Slide 21 Special Characters (Introduction) Some characters (*, ?, +, and others) have special meaning when creating regular expressions These characters are called metacharacters To include these characters as literal characters in a regular expression, they must be escaped The \ is the escape character

Slide 22 Special Characters (List)  \n  \r  \t  \\  \|  \-  \^  \?  \*  \+  \{  \}  \(  \)  \[  \]  linefeed  carriage return  tab  The backward slash \  The vertical bar |  The hyphen -  The caret ^  The question mark ?  The asterisk *  The plus sign +  The open curly brace {  The close curly brace }  The open paren (  The close paren )  The open square bracket [  The close square bracket ]

Slide 23 Special Characters (.) The dot (.) matches any character (except for the newline character) Thus, the following would match any character followed by the digit 0.0

Slide 24 Character Classes (List 1) \s matches a space \S matches any character that is not a space \d matches any digit \D matches any character that is not a digit \w matches a word \W matches any character sequence that is not a word

Slide 25 User Defined Character Classes (1) We can tell the regular expression engine to match a range of characters Square brackets surround the range Only one character can appear in the range

Slide 26 User Defined Character Classes (2) A hyphen can appear in a character class to denote a range Multiple ranges can appear in a character class The order of ranges is not significant Examples A name beginning with a letter followed by any sequence of upper-case or lower-chase characters

Slide 27 Negation The caret "^" is the negation character when used in a character class A "q" followed by any sequence of characters that is not a "u"

Slide 28 Start of Pattern and End of Pattern Anchors are used to match a position "^" matches the start of a pattern "$" matches the end of the pattern

Slide 29 Alternation Alternation is basically a logical or The vertical bar is the alternation symbol Example: The following matches "cat" or "dog"

Slide 30.NET and Regular Expressions The System.Text.RegularExpressions namespace contains classes designed to match regular expressions against a string A Match object is returned by a pattern- matching operation

Slide 31 Testing a Regular Expression The following statement runs a regular expression against a string and returns a Match: Dim Result As _ System.Text.RegularExpressions. _ Match Result = _ System.Text.RegularExpressions. _ Regex.Match(txtString.Text, _ txtPattern.Text)