Solved

ASP.NET VALIDATION (Client verse Server)

Posted on 2004-03-23
4
250 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
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

735 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