ganjeii
ganjeii

Reputation: 1178

MVC C# separate validation message at bottom of form

I already have basic model validation figured out in my MVC application, but I'm also looking to add a message at the bottom of a form simply stating that there were errors. Since it's a fairly long form the user may not know why they were re-directed back to the form since they may not be able to see the errors unless they scroll up on the page.

What is the best way to do this in MVC? I'm having trouble finding an example. Might I have to create a property in the model just for this and apply a [Required] annotation to it with a message, then somehow trigger it via the controller if the Modelstate.Valid is false?

Upvotes: 0

Views: 185

Answers (1)

Tarek Abo ELkheir
Tarek Abo ELkheir

Reputation: 1331

I think you could use validationsummary

look here validationsummary

Upvotes: 1

Related Questions