01 June 2011

Interview questions Validation controls .net

Topic : Validation Controls

Contributed by : Keerthy C

Q. Define Validation Control in ASP.NET.

Answer: The validation control is used to implement page level validity of data entered in the server controls. This check is done before the page is posted back to the server thus avoid round trip to the server. If data does not pass validation, it will display an error message to the user.

Q. Describe the steps to use Validation Control.

Answer: Draw a validation control on a Web form
Set the ControlToValidate property to the control you want to validate.
Specify the ControlToCompare property with CompareValidator control.
Specify error message to the validation control’s ErrorMessage property.
Specify error message to the validation control’s Text property if you want to display a message other than the message in the ErrorMessage property.
Draw a ValidationSummary control on the Web form to display the error messages from the validation controls in one place.

Contributed by: Saravana Kumar

Q.Name two properties common in every validation control?

Answer.ControlToValidate property and Text property.

Reference:
http://www.allinterview.com/showanswers/4646.html
http://www.dotnetspark.com/qa/571-name-two-properties-common-every-validation.aspx

Q: Where do the ASP.NET validation controls validate data, on the Client or on the Web Server?

Answer: ASP.NET validation controls validate data on the client as well as web server. If we need to
validate data on client side itself, we have to set a property to controls to execute at the client side.

Reference:
http://www.clear-interviews.com/2010/07/where-do-aspnet-validation-controls.html
http://www.clear-interviews.com/2010/07/aspnet-validation-controls-faqs.html
http://msdn.microsoft.com/en-us/library/aa479013.aspx

Contributed by : Pinky Bhadran

Q.How many types of validation controls are provided by ASP.NET? Explain them.

Answer: Five Types of validation control exists:

RequiredFieldValidator: To enforce a user to fill a particular field before submitting the form. This
is done when the field is a mandatory input .e.g.: username & password
RangeValidator: To validate if the user input fits within a range of lower and upper limits.
CompareValidator: This is to compare the user input against other existing value.
RegularExpressionValidator: This is to ensure that the use input is as per the expected pattern.e.g.: Phone number, emails
CustomValidator: Custom validator allows developers to create their own validators based on
their logics. This could be a mix of other validators.

References : www.msdn.microsoft.com/en-us/library/aa479045.aspx


For the latest IT jobs visit  www.ipsrjobs.com 

No comments:

Post a Comment