0

i have as asp.net-mvc website and we are migrated a popup from using PartialView() on the server to just return Json() response (and do the bindings on the client side). In this case, it seems about 10 times faster which is great.

the one issue i ran into is that the existing code leveraged ModelState alot for validation and UI highlighting of issues.

Is there a suggested way to do validation if i am now just recieving Json() responses from the server.

in particular: 1. what is the preferred way to returning ModelState Errors to the Gui (and get the same red highlighting and binding that you get out of the box with asp.net-mvc modelstate. 2. Should i still use modelstate or ditch it for another complete solution. 3. anything else to worry about during this migration.

leora
  • 188,729
  • 360
  • 878
  • 1,366

1 Answers1

1

You'd have to return a json result with some sort of error flag along with a modelstate converted to json then you could use that on the client side to apply the right css. This question has an example: How to read modelstate errors when returned by Json?

Also http://bradwilson.typepad.com/blog/2010/10/mvc3-unobtrusive-validation.html

Community
  • 1
  • 1
maciek
  • 661
  • 4
  • 10