3

I'm having problems the default Html.ValidationSummary() in MVC 3.

As default it adds this code:

<ul>
  <li style="display:none"></li>
</ul>

And that empty <ul> causes space I would like to get rid of.

Is there some way to work around this problem? Make it toggle some div around it or similar?

Lasse Edsvik
  • 9,070
  • 16
  • 73
  • 109

2 Answers2

8

how about conditionally showing ValidationSummary

if(!ViewData.ModelState.IsValid)
 {
     @Html.ValidationSummary() 
 }

important if you do this you won't be able to use client-side javascript validation (as the div wont be present)

wal
  • 17,409
  • 8
  • 74
  • 109
2

You can create your own validation summary, for example, like here: Custom ValidationSummary template Asp.net MVC 3

Community
  • 1
  • 1
webdeveloper
  • 17,174
  • 3
  • 48
  • 47