Asp net form not validating

Rated 3.89/5 based on 908 customer reviews

The MVC framework provides several helper methods to display useful error messages to the user. This is used when you have to ensure that two or more properties interact correctly.

asp net form not validating-42

asp net form not validating-72

asp net form not validating-45

To enforce these requirements, I use model validation.

Displaying all error messages on the top of the form might be ok if the form is as short as mine but if the form has 20 rows, the user will be confused with all the error messages.

The solution for this is the Validation Message For HTML helper.

Adding a model level error to the Model State is also achieved by using the Add Model Error with the difference that the first parameter is an empty string.

Additionally, you have to pass true as the parameter for the Validation Summary in the view.

Leave a Reply