Server side validation controls in [Resolved]

Posted by Programmer123 under ASP.NET on 9/23/2013 | Points: 10 | Views : 2333 | Status : [Member] | Replies : 2
Can any one tell me how server-side controls are working as client side validation?


Posted by: Allemahesh on: 9/24/2013 [Member] [MVP] Silver | Points: 50


When you click on the button (if you defined CausesValidation="true") button send request to server with __doPostBackWithOptions function aims which contains valiadtion group as parameter (if you defined ValidationGroup property for your button). __doPostBackWithOptions contains function Page_ClientValidate. In this case will be checked all validators which belong for this group. If result (Page_IsValid) will be true postback occures. If You don't define validationGroup (but CausesValidation true) will be checked all validators which is present on page. If defined CAusesValidation false will use _doPostBack function without validators checking. More information here:

Happy Coding,
If it helps you or directs U towards the solution, MARK IT AS ANSWER

Programmer123, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 9/24/2013 [Member] [MVP] Platinum | Points: 25

Types of Validation
There are two ways we can perform validation:
*. Client side validation
*. Server side validation

Client Side Validation
Client side validation is something that will happen on users' browser. The validation will occur before the data gets posted back to server. It is a good idea to have client side validation as the user gets to know what needs to be changed immediately, i.e., no trips to servers are made. So from the users' point of view, it gives him fast response and from the developers' point of view, it saves valuable resources of server.

JavaScript is most widely used to perform client side validation. From decades, developers have been using JavaScript for client side validation. It is always a good idea to have knowledge of JavaScript as it gives us full control over client side validation. Now Microsoft is also embracing jQuery in its current versions so perhaps JavaScript and/or Jquery should be the right thing to use for client side validation.

JavaScript provides full control to the developer on how client side validation should happen but developers will have to write the validation code themselves. ASP.NET also provides some validation controls to perform client side validation which could help the developers in putting client side validation in place without writing a lot of code. These controls will also use JavaSscript underneath to perform validations. We will see these controls in a moment.

Server Side Validation
Server side validation occurs at server. The benefit of having server side validation is that if the user somehow bypasses the client side validation (accidentally or deliberately), then we can catch the problem on the server side. So having server side validation provides more security and ensures that no invalid data gets processed by the application.

Server side validation is done by writing our custom logic for validating all the input. ASP.NET also provides us some controls which will facilitate the server side validation and provides a framework for the developers to do the same.

NOTE: Web developer may choose to go with any one type of validation but usually it is a good idea to have client side validation and same validation on server side too. It sure takes some resources of server to validate the already validated data (on client side) but it ensures security and that is always good.

Validation Controls in ASP.NET
1) RequiredFiledValidator
2) CompareValidator
3) RangeValidator
4) RegularExpressionValidator
5) CustomValidator
6) ValidationSummary


Mark This Response as Answer

Programmer123, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response