Solved

ASP.NET VALIDATION (Client verse Server)

Posted on 2004-03-23
4
251 Views
Last Modified: 2010-04-17
I am having some trouble understanding what the ASP.NET validation controls actually do.

Do they validate on the client, the server, or both?

I understand the customvalidator has an event called onServerValidate which can be used to trigger server validation.  

But what about the requiredfieldvalidator, rangevalidator, etc, etc.  There is a setting that says EnableClientScript.  I have set this to false and have mixed results.  In some cases the validation doesn't work anymore and in other cases it works fine.  

I don't know if I should be creating client and server side validation routines.  If so, how do I do both at the same time?
0
Comment
Question by:ijenkins
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 1

Accepted Solution

by:
minermadison earned 250 total points
ID: 10663284
ASP.Net Validation controls generate client side JavaScript, when the 'EnableClientScript' is set to true the script is in an .js file located at

http://localhost/...SiteName.../aspnet_client/system_web/1_1_4322/WebUIValidation.js

Most all users have Javascript enabled to you should be safe using the 'EnableClientScript'. This way, when the user presses the 'submit' button, validation takes place immedaitly on the clients machine, otherwise a round trip to the server is made, possibly just to send the page back with some red ink telling the user that a field value is incorrect.

The best practice I've found is to use the ValidationControls with the client script. And also write some server based code to double check the values, if they don't look write you can take the appropraite action.
0
 
LVL 44

Assisted Solution

by:Arthur_Wood
Arthur_Wood earned 250 total points
ID: 10663578
You do not need to 'create client and server' validation routines.  Just create the 'validation' routine, as is, and ASP.NET will take care of what is needed.  (actually, the validation is 'normally' done on BOTH sides - using the same code, as provided by you).

AW
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an explanation of a simple data model to help parse a JSON feed
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question