























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
In the world of internet, web programming is evolving and increasing its importance exponentially. This lecture key points are: Asp Validation Controls, Server Processing Model, Checking the Validators, Requiredfieldvalidator, Regular Expressions, Implementations, Literal Values, Quantifiers, Numeric Range, Special Characters
Typology: Slides
1 / 31
This page cannot be seen from the preview
Don't miss anything!
























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
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
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
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
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
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
The client validation function must accept two arguments The first contains the object that fired the event The second contains the event data
It validates another control instance against a regular expression The regular expression is stored in the ValidationExpression property
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
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
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"
1 can appear 0-1 times and 5 can appear 0- times This pattern also matches an empty string because 1 or 5 can appear 0 times
Quantifiers allow us to specify how many times a pattern can occur Numeric range quantifiers appear in curly braces