Solved

ASP.NET VALIDATION (Client verse Server)

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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

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
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Starting up a Project

717 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