Solved

ASP.NET VALIDATION (Client verse Server)

Posted on 2004-03-23
4
246 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
Comment Utility
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
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
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 …

762 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now