Charanoglu
Charanoglu

Reputation: 1339

Cannot add style to ValidationSummary

I'm trying to add a style to @Html.ValidationSummary(), essentially I want display the error message as red and in a bold text, so I wrapped this in the following tag:

<p class="text-danger font-weight-bold">@Html.ValidationSummary()</p>

I used the Bootstrap class, but the result is even the same, and also the generated html by @Html.ValidationSummary() is added outside the p tag.

Someone has encountered a similar situation?

Thanks in advance.

Upvotes: 0

Views: 1748

Answers (1)

D Ie
D Ie

Reputation: 841

Try with

@Html.ValidationSummary(true, "", new { @class = "text-danger font-weight-bold" })

That's using bootstrap's "text-danger" class, you could create your own in a css file, add whatever rules you want and apply it specifying the classname

Upvotes: 3

Related Questions