我在C#控制器中创建了一个下拉列表,并使用一个@Html.DropDownListFor来显示它。
问题是我想以红色显示选定的值。当用户转到修改页面以更改他/她的选择和下拉时会发生,然后应该以红色显示他以前选择的内容。
我已经创建了下拉列表,现在用户可以看到以前选择的值。我只是不知道如何改变c#代码中的颜色
if (financierEntity.EntityId == selectedFinancierEntityId)
{
SelectListItem sli = new SelectListItem
{
Text = financierEntity.NodeName,
Value = financierEntity.EntityId.ToString(),
Selected = true,
// need to change the text in red color ?
};
}这是我的代码
@Html.DropDownListFor(model => model.SelectedFinancier, Model.FinancierEntities)发布于 2016-06-09 02:54:16
我还没有试过这些代码,但是这些代码行上的一些东西应该可以工作:
<select name="SelectedFinancier">
@foreach (var item in Model.FinancierEntities)
{
<option value="@item.Value"
@(item.Selected ? "selected" : "")
style="color: red">@item.Text</option>
}
</select>https://stackoverflow.com/questions/37715751
复制相似问题