Waqar Malik Waqar Malik - 2 months ago 16
ASP.NET (C#) Question

How to make validation summary show red text and make bullet point not show?

Just a quick question, I want to make the bullet point not show on my validation summary and also I want to make the text red. I was just wondering how to do this, please check my code below.

<div class="help-block col-md-12" style="list-style-type:none">
@Html.ValidationSummary(true)
</div>

Answer

Change your call of ValidationSummary extension method like this:

@Html.ValidationSummary(true, "", new { @class = "custom-validation-summary" })

It will add the css class custom-validation-summary to the rendered html element which represents the summary, and than you can change the look with css:

<style>
.custom-validation-summary ul {
   list-style-type:none;
   color: red;
   padding: 0;
}
</style> 

Here is simple MVC fiddle https://dotnetfiddle.net/wTZbmb

Comments