How to define a color of an Html.Displayfor?

Asked

Viewed 133 times

0

In my application I have this Html Helpers:

@Html.DropDownList("estado", new List<SelectListItem>{
    new SelectListItem {Text="Pago", Value="Pago"},
    new SelectListItem {Text="Pendente", Value="Pendente"}
    }, "Selecione o Estado:", new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.estado, "", new { @class = "text-danger" })

And here is where I display the selected item, ie if it was chosen Paid or Pending:

<td>
    @Html.DisplayFor(modelItem => item.estado)
</td>

So I’d like you to be chosen Paid it was written in green, case Pending that is displayed on red color, how to solve this problem?

  • Not just a Javascript? type after choosing change this item to the desired colors?

  • A certain Virgilio, but give me an example of this in practice, because I tried in many ways and did not give!!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.