Documente Academic
Documente Profesional
Documente Cultură
Input validation verifies that the user has correctly filled in an input
control, before the request is processed on the server
Input validation:
Error Message
Valid?
No Yes
Server
Server-side validation:
Repeats all client-side validation Validates against stored data or other server-side resources
Valid?
Yes
No
RegularExpressionValidator Control
CustomValidator Control Combining Validation Controls
Form
Validation Control
RequiredFieldValidator CompareValidator
Function
Requires user input Compares input values
RangeValidator
RegularExpressionValidator
CustomValidator
ValidationSummary
CompareValidator
RegularExpressionValidator Control
The RegularExpressionValidator control verifies if the user input matches a predefined pattern Visual Studio 2008 SP1 Regular Expression Editor includes patterns for: Telephone numbers Postal codes and zip codes E-mail addresses URLs Social security numbers
<asp:RegularExpressionValidator id="EmailRegexValidator" runat="server" ControlToValidate="EmailTextBox" ErrorMessage="Use the format username@organization.xxx" ValidationExpression="\w+@\w+\.\w+" Text="*" /> The following markup shows how you can use a RegularExpressionValidator control to check if a user has entered a valid e-mail address <asp:TextBox id="EmailTextBox" runat="server" />
CustomValidator Control
You can validate on the client side and server side by using the: ClientValidationFunction method OnServerValidate method
RequiredFiel dValidator
CustomVali dator
id="MyValidationSummary"
runat="server" HeaderText="These errors were found:" ShowSummary="True"
DisplayMode="List" />
An application state stores global information used across multiple session and requests. The Application object generally holds information that will be used by multiple pages of the application
13
The Unlock() method is used to unlock the locked variables stored in the Application object.
Properties Method
15
16
Events
17
Global.asax
Global.asax file is referred to as an ASP.Net application file , which contains the code for responding to application or module-level events in one central location.
The Global.asax file is an optional file and created only if the application or session events need to handled
The Global.asax file is located in root application directory with .asax extension
18
Global.asax
When a new ASP.Net application is created with Visual Studio 2005 IDE , a Global.asax file is automatically added to project. Every ASP.Net Web applocation can have one, and only Global.asax file
19