How to get the error message from model state
-
22-09-2019 - |
Question
I'm using
modelstate.Adderror("test","test message")
And how can i get this modelstate value in controller itself.
Like I need to get the error message of "test" in the controller.
Solution
He asks for in the controller, I cannot verify this but I think this is simply something like:
ModelState["test"].Value
ModelState["test"].Error
ModelState["test"]
One of those above.
OTHER TIPS
Try <%=Html.ValidationMessage("Test") %>
.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow