Show ValidationSummary MVC3 as “alert-error” Bootstrap

后端 未结 16 997
情书的邮戳
情书的邮戳 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:29

    Alternative solution with pure javascript (jQuery). I'm working with MVC4 + Bootstrap3 but it works perfect for you.

    $(function () {
            $(".validation-summary-errors").addClass('alert alert-danger');
            $(".validation-summary-errors").prepend('')
        });
    

    If you don't want to write server side logic then is a nice alternative solution.

提交回复
热议问题