Show ValidationSummary MVC3 as “alert-error” Bootstrap

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

    You can use jquery:

    $(function(){
     $('.validation-summary-errors.alert.alert-error.alert-block').each(function () {
         $(this).prepend('');
     });
    });
    

    It is looking for every div containing given error classes from bootstrap and writing html at beginning of the div. I am adding .alert-block class as the bootstrap page says:

    For longer messages, increase the padding on the top and bottom of the alert wrapper by adding .alert-block.

提交回复
热议问题