ExpertRating - Online Certification and Employment Testing ExpertRating - Online Certification and Employment Testing ExpertRating - Online Certification and Employment Testing

ExpertRating Home
ExpertRating Benefits
Recommend ExpertRating
Suggest More Tests
Privacy Policy
FAQ
Login
 
ASP Dot Net Tutorial - Index
ASP Dot Net Tutorial - Microsofts ASP.NET
ASP Dot Net Tutorial - Begining Web Forms
ASP Dot Net Tutorial - User Controls
ASP Dot Net Tutorial - ADO .NET
ASP Dot Net Tutorial - DataBinding to WebControls
ASP Dot Net Tutorial - DataList Controls
ASP Dot Net Tutorial - DataGrid Control
ASP Dot Net Tutorial - Advance Practical Examples on DataGrid
ASP Dot Net Tutorial - Working with DataSets
ASP Dot Net Tutorial - Working with XML
ASP Dot Net Tutorial - Forms Based Authentication
ASP Dot Net Tutorial - Windows Based Authentication
     

 
Online Personal Trainer Certification
Test Search by Job Title
Find a Personal Trainer
Job Resources
Free Self Tests and Quizzes
Find a Lawyer
Project Management Certification
Six Sigma Certification
Six Sigma Black Belt Certification
Six Sigma Green Belt Certification
Lean Management Certification
First Aid Certification
CPR Certification
Yoga Certification
Aerobics Certification
Pilates Certification
SEO Certification
Online Photography Course & Certification
Online Business Writing Course & Certification
Baby Sitting Course & Certification
Time Manangement Certification
Health Club Management Certification
Selling Skills Certification
Business Analysis Course
Green Living Course  free!
Master Trainer Certification
Total Quality Management Certification
Kaizen Certification
Creative Writing Certification
  All Online Courses
   

   
   
   
   
   
   

   
  Home > Courses, Tutorials & eBooks > ASP.NET Tutorial > User Controls
 

ASP.NET Tutorial - User Controls

                                                                                                                 Page 3 of 5
 

The following table lists the types of validation controls available and how you can use them.

Type of validation
Control to use
Description
Required entry RequiredFieldValidator

Ensures that the user does not skip an entry.

Comparison to a value CompareValidator Compares a user's entry against a constant value, or against a property value of another control, using a comparison operator (less than, equal, greater than, and so on).
Range checking RangeValidator Checks that a user's entry is between specified lower and upper boundaries. You can check a range within pairs of numbers, alphabetic characters, and dates.
Pattern matching RegularExpressionValidator Checks that the entry matches a pattern defined by a regular expression. This type of validation allows you to check for predictable sequences of characters, such as those in social security numbers, e-mail addresses, telephone numbers, postal codes, and so on.
User-defined CustomValidator Checks the user's entry using validation logic that you write yourself. This type of validation allows you to check for values derived at run time.

Let us see an example of above controls.

Example 14 RequiredFieldValidator.aspx

<Script Runat="Server">

Sub Button_Click( s As Object, e As EventArgs )

If IsValid Then

Response.Redirect (“Thanks.aspx”)

End If

End Sub

</Script>

<html>

<head><title>RequiredFieldValidator.aspx</title></head>

<body>

<form Runat="Server">

Username:

<br><asp:TextBox

ID="txtUsername"

Runat="Server" />

<asp:RequiredFieldValidator

ControlToValidate="txtUsername"

Text="You must enter a username!"

Runat="Server" />

<p>

Password:

<br>

<asp:TextBox

id="txtComments"

Runat="Server"/>

<asp:RequiredFieldValidator

ControlToValidate="txtComments"

Text="You must enter some comments!"

Runat="Server" />

<p>

<asp:Button

Text="Submit"

OnClick="Button_Click"

Runat="Server"/>

</form>

</body>

</html>

 

The output of this example is shown below:

In this example if we do not enter the vales into the textboxes and submit the form then the RequiredFieldValidator controls displays error message and the IsValid property has the value false. Otherwise, the Button_Click subroutine automatically redirects you to a page named Thanks.aspx

       

 

 
     
Home  |  About Us  |  Privacy Policy  |  Site Map  |  FAQs  |  Contact Us
 
© ExpertRating 2006. All Rights Reserved.