My Profile

Thursday, February 10, 2011

ASP.Net - CompareValidator & ValidationSummary


Now we’ll see few more validation controls…

1.    CompareValidator:
·       It is a control which performs all validations related to comparison of controls.
·       This control can be used to perform 3 types of comparisons. Those are:
i.                   Control – Control:
With this use of this CompareValidator control, we can compare two different controls.
Apart from common properties this control has some more properties, those are:
Properties:
·       ControlToValidate : <controlname>
·       ControlToCompare : <controlname to which we are comparing>
·       Type : data type
·       Operator : Equal/NotEqual/GreaterThan….
ii.                Control – Value:
With this use of this control, we can compare the control with some value we specify.
Properties:
·       ControlToValidate :
·       ValueToCompare :
·       Type :
·       Operator :

iii.              Control – Data Type:
With this use of this property, we can compare the control with Data Type specified.

Properties :
·       ControlToValidate :
·       Type :
·       Operator : DataTypeCheck *

2.    ValidationSummary:
·       This control doesn’t perform any validations but reports all validation control error messages at one place. That is why it is called summary control. Display property with None value can be used for the Validation control Error messages in this kind of situations. Because, we want to display errors only at one location and that is near control or separately.
·       To use it, we have to just place it on the form and it automatically gets messages.
Properties:
·       ShowMessageBox : true/false(d)
When true, then VS will display error messages in separate alert window.
·       ShowSummary: true(d)/false
When false, within the form, summary control will not display the errors.

Note: when SummaryControl is present in form then ErrorMessage will appear in Summary control and Text will appear in place of validation Control (Useful).

 
---------------------------------------------------------- 
** If you like this post please like our page in 
facebook " Dot Net Support"

0 comments:

Post a Comment

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More