ASP.NET Tutorials
Tutorials
ASP.NETASP .NET: Validating User Input with C#
Table of Contents
ASP .NET: Validating User Input with C#
Required Field Validator
Regular Expression Validator
Range Validator
Compare Validator
Custom Validator
Validation Summary ControlASP .NET: Validating User Input with C#
This tutorial covers Validating User Input with C# covers Overview of ASP.NET Validation Controls , Using the Simple Validators , Using the Complex Validators and Summarizing Results with the Validation Summary Control.
In this tutorial we will see the validation controls. The purpose of the validation controls is to validate the user input. Asp.net provides the developer with different types of validation controls. One most important point to note is that the validation is done on the client side as well as on the server side. You can always turn the validation on the client side off using the enable client side property to false. Lets see the difference between the client side validation and the server side validation.
Client side validation
When you place validation code on the client side, validation does not require a postback operation and provides fast responses to the user. However, because the validation code is outside the Web Server, it might be possible for the client to spoof the Web Server with invalid data. The addition to this, client-side validation requires the client to be capable of running scripts. That might be an issue with old browsers and some new browsers in which users turn off script execution thinking that scripts are unsafe. This client-side validation should never be used as the only validation technique to validate data on a Web page.
Server Side Validation
When the validation code is placed the server side, the process of validation might be slow because a form might involve multiple roundtrips to the Web Server before all the data is validated. On the other hand, because the Web Server is performing all the validation, you can trust the validated data. Server-side validation works well with even primitive browsers because it does not assume any specific browser capabilities.
(MCAD/MCSD Developing and implementing Web Applications with Visual C# .NET and Visual Studio. NET)
Next Page: Required Field Validator
Comments
debu_2005_abcd said:
| The course material is very helpful |
Allan Joey Laluan said:
| :D Good day! I used validators in my web app and running them locally but my problem is when I copy the system in the live environment the validator did not work. Any possible solution? I check the properties of the validator and compare them in all the examples found in the internet but I have the same result. Can you help me in my problem? :'( |
satish singh said:
| this will be really helpful not only for experienced developers but for beginners also. |
toy said:
|
how can i get the page to pass thru if its not valid ie, id like to be able to write some like this if (Page.IsPostBack) { Page.Validate; if (Page.IsValid) { do seomthing } else { do something else } } but the something else doesnt work cuase as soon as it doesnt pass the validators it never gets past the postback am i barking up the wrong tree here? thanks for any help |
SHRADDHA NIGAM said:
|
This is really a very helpful n nice article. I really behefited from it and enjoyed it. ;D |
Vaibhav Kulkarni said:
|
Hi , This is vaibhav. I recently started to learn self .NET. Initially i found it to be harder than j2EE but tnow I realised that its a preety easy. This article helped me alot to know the basic concepts. |
cathy said:
| thank you very much, help me solve a tough problem^^ |
Rajesh.k said:
| I had some doubt in validaton ontrols .. now i got some idea after reaing this article.. thanks for this aticle writer........... |
Jemson Sentillas said:
|
Thanks for the nice article..solve my problems.. --jamesbond-- |
Aradhita said:
|
This is a compact and easy to read n understand material. This is very very useful for quick review. Thanksto the writer. |
