josephj1989
josephj1989

Reputation: 9709

MVC3 ValidationSummary(No) not suppressing detail errors

I have a MVC3 razor form where I use @Html.ValidationSummary(false)

It displays all errors including field errors at the top but it also displays field errors at field level. Is there a way to display at top only

thanks

Upvotes: 2

Views: 384

Answers (1)

Paul Fleming
Paul Fleming

Reputation: 24526

You need to remove the Html.ValidationMessageFor(...) lines. These are the inline validation messages and are unrelated to ValidationSummary.

Edit: Making it optional:

@{var bool bInline = true;}
@Html.ValidationSummary(bInline)

@Html.LabelFor(m => m.MyField)
@Html.EditorFor(m => m.MyField)
@if (bInline)
{
    @Html.ValidationMessageFor(m => m.MyField)
}

Upvotes: 1

Related Questions