I I need to validate some thing in mvc in my controller I have to
@Html.ValidationMessageFor(model => model.somestring)// in the view
if (model.string = some condition)
ModelState.AddModelError("somestring", "String cannot be empty");// in the controller
but if in my view I have a custom object like
@Html.ValidationMessageFor(model => model.someobject.somestring)// in the view
how do I validate it? Is the following syntax correct?
if (model.someobject.somestring = some condition)
ModelState.AddModelError("somestring", "String cannot be empty");// in the controller