我想显示一个ValidationSummary mcv3与“alert-error”Bootstrap样式。
@Html.ValidationSummary(true,"Errors: ")
<div class="validation-summary-errors"> <span>Errors:</span> <ul> <li>Error 1</li> <li>Error 2</li> <li>Error 3</li> </ul> </div>
我也试过这个:
@Html.ValidationSummary(true,"Errors:",new { @class = "alert alert-error" })
并且它工作确定,但没有关闭按钮(X)
<div class="validation-summary-errors alert alert-error"> <span>Errors:</span> <ul> <li>Error 1</li> <li>Error 2</li> <li>Error 3</li> </ul> </div>
但Bootstrap警报应该有这个按钮进入div:
<button type="button" class="close" data-dismiss="alert">×</button>
任何人可以帮助?
这工作! – 感谢Rick B
@if (ViewData.ModelState[""] != null && ViewData.ModelState[""].Errors.Count() > 0) { <div class="alert alert-error"> <a class="close" data-dismiss="alert">×</a> <h5 class="alert-heading">Ingreso Incorrecto</h5> @Html.ValidationSummary(true) </div> }
我还必须从“site.css”中删除类“.validation-summary-errors”,因为该样式定义了其他字体颜色和权重。
解决方法
再次编辑
我首先误解了你的问题。我想以下是你想要的:
@if (ViewData.ModelState[""] != null && ViewData.ModelState[""].Errors.Count > 0) { <div class="alert alert-error"> <button type="button" class="close" data-dismiss="alert">×</button> @Html.ValidationSummary(true,"Errors: ") </div> }