Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: MVC3
Hi friends,
 
I have just started to use the MVC 3.0.
Please suggest me how we apply the validation on the page.
 
I am very confused how to validate the data
and what level
I have tried google but it was totally out of my scope
 
1)Model level validation
2)custom validation
3)self validation model.
4)Remote validation.
5)Server side validate.
 
Please help me.
Thanks
Posted 3-Aug-12 23:27pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You can do what ever you like. You should ALWAYS validate on the server, client side validation can be easily hacked. You can write client side code, too. It's possible to annotate your viewmodel, but only to the top level, so you can't have a class inside your viewmodel and then have the properties of that class be validated using the built in validation. For me, this is reason alone to never use it, but you can.
 
Just make sure you always validate on the server, and add client side validation for convenience, using whatever method you like.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 330
1 Richard Deeming 240
2 Nirav Prabtani 212
3 CHill60 170
4 _Amy 165
0 OriginalGriff 8,104
1 Sergey Alexandrovich Kryukov 7,045
2 Maciej Los 4,039
3 Peter Leow 3,738
4 CHill60 2,912


Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 4 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100