Validations
Interview Questions on ASP.Net(28)
1. Should user input data validation
occur server-side or client-side?Why?
A.All user input data validation should
occur on the server at a minimum.Additionally, client-side validation can be
performed where deemed appropriate and feasable to provide a richer, more
responsive experience for the user.
2.How many types of validation controls
are provided by ASP.NET ?
A.There are six main types of
validation controls.
3.Name two properties common in every
validation control?
A.ControlToValidate property and Text
property.
4.How do you validate the controls in
an ASP .NET page?
A.Using special validation controls that
are meant for this. We have Range Validator, Email Validator.
5.Can the validation be done in the
server side? Or this can be done only in the Client side?
A.Client side is done by default. Server
side validation is also possible. We can switch off the client side and server
side can be done.
6.What are the validation controls?
A.A set of server controls included with
ASP.NET that test user input in HTML and Web server controls for
programmer-defined requirements. Validation controls perform input checking in
server code. If the user is working with a browser that supports DHTML, the
validation controls can also perform
validation using client script.
7.List the different types of validation
controls?
A.There are six types of validation
controls.They are:
1.RequiredField Validator
2.Range Validator
3.Compare Validator
4.RegularExpression Validator
5.Custom Validator
6.Validation Summary
8.Define RequiredField Validator?
A.It checks whether the control have
any value. It's used when you want the control should
not be empty.
9.Define Range Validator?
A.It checks if the value in validated
control is in that specific range. Example TxtCustomerCode should not be more
than eight length.
10.Define Compare Validator?
A.It checks that the value in controls
should match the value in other control. Example Textbox TxtPie should be equal
to 3.14.
11.Define RegularExpression Validator?
A.When we want the control value should
match with a specific regular expression.
12.Define Custom Validator?
A.It is used to define UserDefined
validation.
13.Define Validation Summary?
A.It displays summary of all current
validation errors.
14.How can we force all the validation
control to run ?
A.Page.Validate()
15.How can we check if all the
validation control are valid and proper ?
A.Using the Page.IsValid() property you
can check whether all the validation are done.
16.If client side validation is
enabled in your Web page, does that mean server side code is not run?
A.When client side validation is enabled
server emit’s JavaScript code for the custom validators. But note that does not
mean that server side checks on custom validators do not execute. It does this
redundant check two times as some of the validators do not support client side
scripting.
17. Which JavaScript file is referenced
for validating the validators at the client side ?
A.WebUIValidation.js javascript file
installed at “aspnet_client” root IIS directory is used to validate the
validation controls at the client side.
18. How to disable client side script in
validators?
A.Set EnableClientScript to false.
19.How can I show the entire validation
error message in a message box on the client side?
A.In validation summary set
“ShowMessageBox” to true.
20.How can you display all validation
messages in one control?
A.The ValidationSummary control displays
all validation messages in one control.
21.Can you set which type of comparison
you want to perform by the CompareValidator control?
A.Yes, by setting the Operator property
of the CompareValidator control.
22.Where should the data validations be
performed-at the client side or at the server side and why?
A.Data validations should be done
primarily at the client side and the server-side validation should be avoided
because it makes server task overloaded. If the client-side validation is not
available, you can use server-side validation. When a user sends a request to
the server, the validation controls are invoked to check the user input one by
one.
23.What is the function of the
CustomValidator control?
A.It provides the customize validation
code to perform both client-side and server-side validation.
24.Which data type does the
RangeValidator control support?
A.The data types supported by the
RangeValidator control are Integer, Double, String, Currency, and Date.
25. How can you check if all the
validation controls on a Web page are valid and proper?
A.You can determine that all the
validation controls on a Web page are properly working by writing code in the
source file of the Web page using a scripting language, such as VBScript or
JavaScript. To do this task, you have to loop across validators collection of
pages and check the IsValid property of each validation control on the Web page
to check whether or not the validation test is successful.
26.Which control will you use to ensure
that the values in two different controls match?
A.You should use the CompareValidator
control to ensure that the values in two different controls match.
27. How do you prevent a validation
control from validating data at the client end?
A.You can prohibit a validation control
to validate data at the client side by setting the EnableClientScript property
to False.
28.Can we validate a DropDownList by
RequiredFieldValidator?
A.Yes, we can validate a DropDownList by
RequiredFieldValidator. To perform this validation, we have to set the
InitialValue property of RequiredFieldValidator control.
0 comments:
Post a Comment