How can I check ModelState.IsValid from inside my Razor view [duplicate]

Solution 1:

Is model state available in the view?

Of course:

@if (!ViewData.ModelState.IsValid)
{
    <div>There are some errors</div>
}

Solution 2:

It's not common to need this in the view itself, but you can access it like so:

@ViewData.ModelState.IsValid