4

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.

GrandMasterFlush
  • 6,269
  • 19
  • 81
  • 104
Santhosh
  • 19,616
  • 22
  • 63
  • 74
  • possible duplicate http://stackoverflow.com/questions/573302/how-do-i-get-the-collection-of-model-state-errors-in-asp-net-mvc – Dave Archer Jan 04 '10 at 09:53

2 Answers2

5

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.

bastijn
  • 5,841
  • 5
  • 27
  • 43
1

Try <%=Html.ValidationMessage("Test") %>.

Çağdaş Tekin
  • 16,592
  • 4
  • 49
  • 58