Tuesday, 8 May 2018

Defination Of Validation and Type of Validation


Defination Of Validation:-

Validation is most part of any web application. It is validate the user input data. It is used to
implement page level validity of data entered in the server controls.

There are two type of validation here:-
A-Client Side Validation
B-Server Side Validation
A-Client Side Validation:-It is good client side validation. Client side validation is dependent on the browser  and also scripting language.
B-Server Side Validation:- server validation will work always whether client validation is executed or not.

There are six types of validation controls in ASP.NET
  1. Required Field Validation Control
  2. Compare Validator Control
  3. Range Validator Control
  4. Regular Expression Validator Control
  5. Custom Validator Control
  6. Validation Summary
Explain Members:-
Members
Describe to members
A.    EnableClientScript
A.    Indicates whether client side validation will take.
B.    ControlToValidate
B.    Indicates the input control to validate.
C.    Enabled     
C.    Enables or disables the validator.
D.    Display      
D.Indicates how the error message is shown.
E.    Text           
E. Error text to be shown if validation fails.
F.    ErrorMessage
F. Indicates error string.
G.    SetFocusOnError   
G. It indicates whether in case of an invalid control, the focus should switch to the related input control.
H.    IsValid
H. Indicates whether the value of the control is valid.
I.      Validate()
I. This method revalidates the control and updates the IsValid property.
J.     ValidationGroup
J. The logical group of multiple validators, where this control belongs.

1-Define Required Field Validation Control :-
          It is very easy and useful validation .You can use it to make sure that the user has entered something in a Textbox control.
For Example:-
<form id="form1" runat="server">
    Last Name:<br />
    <asp:TextBox runat="server" id="txtLastName" />
    <asp:RequiredFieldValidator runat="server" id="reqName" controltovalidate="txtName" errormessage="Please enter your Last name!" />
    <br /><br />
    <asp:Button runat="server" id="btnsave" text="Submit" />
</form>

Last Name

Please Enter Last Name
2-Define Compare Validator Control:-
              Compare Validator Control is used to compares the value of one input control to the value of another input control or to a fixed value and used between to input value in textbox.


For Example:-
Password :<br />
<asp:TextBox runat="server" id="txtPass" /><br /><br />
Retype Password:<br />
<asp:TextBox runat="server" id="txtRtyPass" /><br />
<asp:CompareValidator runat="server" id="PAAS_Number" controltovalidate=" txtPass " controltocompare=" txtRtyPass " errormessage="The Password should be Retype Password is Same!" /><br />


Password
Reset*123
Retype Password
Reset*1234
The Password should be Retype Password is Same

3-Define RangeValidator :-

The Range Validator Server Control which checks to see if a control value is within a valid range. The attributes that are necessary to this control are: big value(It specifies the minimum value of the rang), small(It specifies the maximum value of the range.) value, and Type(Currency, Date, Double, Integer, and String).

Date:<br />
<asp:TextBox runat="server" id="txtDate" />
<asp:RangeValidator runat="server" id="Daterang" controltovalidate="txtDate" type="Date" minimumvalue="01-01-2018" maximumvalue="31-12-2018" errormessage="Please enter a valid date within 2018!" />
<br /><br />

     For Example:

Date
31-02-2018
Please Enter a valid date within 2018

 

                       

4-Define Regular Expression Validator:-

The Regular Expression Validator permit to validating the input text by matching against a pattern of a regular expression. The regular expression is set in the Validation Expression property and used to identify simple and complex characters sequence that would otherwise require writing code to perform.
For Exmaple of Email Id:-
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" Style="top334px;
        
left400pxpositionabsoluteheight20pxwidth150px" 
        
ErrorMessage="RegularExpressionValidator" ControlToValidate="txt5" 
        
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
Enter Email_ID
princes.com
Please Enter a valid Email_id
 
  1.           Custom Validator Control

5-Define Custom Validator Control:-

The Custom Validator control permitted to writing application specific custom validation routines for both the client side and the server side validation. The control permit to validate both client side and server side, where the server side approach is probably the most powerful. Of course, doing server side validation requires a post back to validate, but in most cases, it’s not really issue. 
For Example:
Custom text:<br />
<asp:TextBox runat="server" id="customtxt" />
<asp:CustomValidator runat="server" id="cusstomcus" controltovalidate="txtCustom" onservervalidate="cusCustom_ServerValidate" errormessage="The text must be exactly 7 characters long!" />
<br /><br />

6-Define Validation Summary Control:-

    
It Defined validation summary control does not perform any validation but shows a summary of all errors in the page. The summary displays the values of the ErrorMessage property of all validation controls that failed validation.
<asp:ValidationSummary ID="valsum1" runat="server"
   DisplayMode = "BulletList" ShowSummary = "true" HeaderText="Errors:" />




No comments:

Post a Comment

What is ASP.NET? Components of ASP.NET

ASP.Net Definition -It is used for creating web-based applications.ASP.Net is a web development platform provided by Microsoft. ASP.NET i...