jquery, c# and server side data validation
Ive been using jquery to post data and was wondering how best to perform serverside validation on the data. I check the values clientside but know its good practice to also check serverside. Ive seached online but cant really find开发者_高级运维 any examples.
Thanks in advance
There are many ways of doing validation server side, but to make it easy for you you could use an existing library.
the Microsoft Enterprise Library 5.0 offers a bunch of features that you can use to implement common practices. Validation is one of them. Microsoft Enterprise Library is a collection of application blocks designed to assist developers with common enterprise development challenges.
The Enterprise Library Validation Application Block provides useful features that allow developers to implement structured and easy-to-maintain validation scenarios in their applications.
a great sample is found at Using Validation Block Attributes to Define Validation Rule Sets
more here: http://msdn.microsoft.com/en-us/library/ff664356(v=PandP.50).aspx
You can either do it manually (ie, if (model.Value != null)
), or via data annotations
Check out ASP.NET server-side validation.
精彩评论