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,119
  • 18
  • 83
  • 102
Santhosh
  • 18,518
  • 21
  • 62
  • 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,681
  • 4
  • 26
  • 42
1

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

Çağdaş Tekin
  • 16,432
  • 4
  • 48
  • 58