Reputation: 2983
I've been using jQuery to post data and was wondering how best to perform server-side validation on the data. I check the values client-side but know it's good practice to also check server-side.
I've searched online but can't really find any examples.
Upvotes: 1
Views: 1299
Reputation: 21864
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
Upvotes: 1
Reputation: 47789
You can either do it manually (ie, if (model.Value != null)
), or via data annotations
Upvotes: 0