Validation By Control ASP.Net

<%@ Page Language="vb" %>


   Validation Control Example
    
    
   
   
      Sub Page_Load()
         vsSummary.DisplayMode = ValidationSummaryDisplayMode.List
      End Sub
      Sub ServerValidation (source As object, args As ServerValidateEventArgs)
         Dim RegExVal As New System.Text.RegularExpressions.Regex("^\d{4}$")
         If RegExVal.IsMatch(args.Value) Then
            args.IsValid = True
         Else
            args.IsValid = False
         End If
      End Sub
   


   

Validation Control Example


   
      
         
            
               CustomValidator Control:
               


               Enter a 4-digit year
            
            
               

                                 controltovalidate="year"
                  errormessage="Not a valid year!"
                  onservervalidate="servervalidation"
                  clientvalidationfunction="ClientValidate"
                  display="dynamic"
                  runat="server"/>
            
         
         
            
               RangeValidator Control:
               


               Enter an integer between 0 and 100
            
            
               

                                 controltovalidate="value" 
                  minimumvalue="0"
                  maximumvalue="100" 
                  type="integer" 
                  errormessage="Value not in valid range!" 
                  runat="server"/>
            
         
         
            
               ValidationSummary Control:
            
            
                                 displaymode="bulletlist" 
                  headertext="Page has the following errors: "
                  showsummary="true" 
                  showmessagebox="false"
                  runat="server"/>