Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I access the ModelState from within my View (aspx page)?

People also ask

How do I show ModelState error in view?

To pass error to the view we can use ModelState. AddModelError method (if the error is Model field specific) or simply ViewBag or ViewData can also be used.

What is ModelState IsValid method where we use it?

ModelState. IsValid indicates if it was possible to bind the incoming values from the request to the model correctly and whether any explicitly specified validation rules were broken during the model binding process. In your example, the model that is being bound is of class type Encaissement .


Use ViewContext.ViewData.ModelState.