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
Personal Trainer Certification (Spanish)
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
Business Analyst Certification
SEO Certification
Online Photography Course & Certification
Online Business Writing Course & Certification
Baby Sitting Course & Certification
Time Management 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 5 of 5
 

 

Example 16 customValidation.aspx

<%@ Page Language="VB" %>

<html>

<head>

<script runat="server">

Sub ValidateBtn_OnClick (sender As object, e As EventArgs)

If Page.IsValid Then

lblOutput. Text = "Page is valid."

Else

lblOutput.Text = "Page is not valid!"

End If

End Sub

Sub ServerValidation (source As object, arguments As ServerValidateEventArgs)

Dim num As Integer = Integer.Parse(arguments.Value)

arguments. IsValid = ((num mod 2) = 0)

End Sub

</script>

</head>

<body>

<form runat="server">

<h3>CustomValidator Example</h3>

<asp:Label id=lblOutput runat="server"

Text="Enter an even number:"

Font-Name="Verdana"

Font-Size="10pt" /><br>

<p>

<asp:TextBox id="Text1"

runat="server" />

&nbsp;&nbsp;

<asp:CustomValidator id="CustomValidator1"

ControlToValidate="Text1"

OnServerValidate="ServerValidation"

Display="Static"

ErrorMessage="Not an even number!"

ForeColor="green"

Font-Name="verdana"

Font-Size="10pt"

runat="server"/>

<p>

<asp:Button id="Button1"

Text="Validate"

OnClick="ValidateBtn_OnClick"

runat="server"/>

</form>

</body>

</html>

 

The output of this example is shown below:

The above example demonstrates how to create a CustomValidation control that validates whether the value entered in a text box is an even number on the server. The validation result is then displayed on the page.

The CustomValidatorcontrol allows creating a validation control with customized validation logic. In above example, a validation control can be created that check whether the value entered into a text box is an even number.

Validation controls always perform validation checking on the server. They also have complete client-side implementation that allows DHTML-supported browsers (such as Microsoft Internet Explorer 4.0 or later) to perform validation on the client. Client-side validation enhances the validation process by checking user input before it is sent to the server. This allows errors to be detected on the client before the form is submitted, avoiding the round-trip of information necessary for server-side validation.

To create a server-side validation function, provide a handler for the ServerValidate event that performs the validation. The string from the input control to validate can be accessed by using the Value property of the ServerValidateEventArgs object passed into the event handler as a parameter. The result of the validation is then stored in the IsValid property of the ServerValidateEventArgs object.

 

       

 

 

 

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