Show ValidationSummary MVC3 as “alert-error” Bootstrap

后端 未结 16 1171
情书的邮戳
情书的邮戳 2021-01-30 00:51

I want to show a ValidationSummary mcv3 with \"alert-error\" Bootstrap styling.

I\'m using a Razor view, and I show model errors with this code:

 @Html.V         


        
16条回答
  •  灰色年华
    2021-01-30 01:32

    If it needs to work with clientside javascript I suggests doing this:

      .validation-summary-valid {
        display: none;
      }
    

    You still can assign the bootstrap class

    @Html.ValidationSummary(null, new {@class= "alert alert-danger" })
    

    but it will only show when you have actual errors.

提交回复
热议问题