I want to pass validation result from server to client and show the message.
Without KnockOut.js it is very simple:
- Call the validation logic.
- Add validation result to ModelState.
- Every thing is hooked automatically. (
Html.ValidationMessageFor
)
What should I do when using KnockOut? What is the best practice here?
Do I need to return my ModelState with my ViewModel? If yes, how should i bind that to my ValidationMessage placeholder? Is there any plugin to use?
update 1:
I know how to use client side validation libraries (Ko validation, jQuery validation) this is not my problem.
I know how to return model state to client using Ajax.
The problem is: What is the standard way of binding my errors list, to UI elements? Do I need to iterate my collection and bind them one by one? Is there any plugin that can bind my model state object to ui?
(just like when you are not using knockout and mvc takes care of it and binds them to your validation message place holders.)