Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Validations in ASP.NET and C#

Tags:

c#

asp.net

Which is best — client-side validation or server-side validation?

like image 924
Bala Avatar asked Sep 02 '10 11:09

Bala


People also ask

What are validation controls in ASP NET?

Validation Controls in ASP.NET. An important aspect of creating ASP.NET Web pages for user input is to be able to check that the information users enter is valid. ASP.NET provides a set of validation controls that provide an easy-to-use but powerful way to check for errors and, if necessary, display messages to the user. Validation Control.

How to validate user input in ASP NET?

ASP (before asp.net) requires manual coding to perform validations. The solution with asp.net is validation controls. Validation controls will provide built in logic to validate user input at client side or server side.

What is requiredfieldvalidator in ASP NET?

ASP.NET - Validators - ASP.NET validation controls validate the user input data to ensure that useless, unauthenticated, or contradictory data don't get stored. ... The RequiredFieldValidator control ensures that the required field is not empty. It is generally tied to a text box to force input into the text box.

How to implement server-side validation in ASP NET?

Let's create a Web application first to implement validation controls in ASP.NET, and then do the server-side validation. Add New web page in your application; here I have added " Register.aspx." Add the following html in your " Register.aspx" page. Now run the application.


2 Answers

Server side validation is a must since client side validation can be tampered. However, client side validation usually provides a better user experience, since it requires less post backs. So I would recommend using both.

like image 120
Klaus Byskov Pedersen Avatar answered Oct 12 '22 02:10

Klaus Byskov Pedersen


You MUST do server side validation. Otherwise anyone can send anything they like (consider browser with JavaScript disabled, or a custom fake browser).

Client site validation can be used to provide a better user experience, but you should operate correctly if it is not available.

like image 28
Richard Avatar answered Oct 12 '22 02:10

Richard