Add Class DropDownListFor

0

How do I insert @class="form-control" into the code below?

    <div class="form-group">
        <label for="disabledSelect" class="control-label col-md-2">Status:</label>
        <div class="col-md-10">
            @Html.DropDownListFor(s => s.Status, new List<SelectListItem>
            {
                new SelectListItem { Value = "Ativo", Text = "Ativo" },
                new SelectListItem { Value = "Inativo", Text = "Inativo" },
            }, @Model.Status, @Model.Status)
        </div>
    </div>
    
asked by anonymous 21.06.2018 / 16:35

1 answer

1

In my case I use the following way.

@Html.DropDownListFor(model => model.Department, (IEnumerable<SelectListItem>)ViewBag.Depts, "", htmlAttributes: new { @id = "departmentList", @class = "form-control" })

In your case, stay that way

@Html.DropDownListFor(s => s.Status, new List<SelectListItem>
{
    new SelectListItem { Value = "Ativo", Text = "Ativo" },
    new SelectListItem { Value = "Inativo", Text = "Inativo" },
}, @Model.Status, htmlAttributes: new { @id = "isActive", @class = "form-control" })
    
21.06.2018 / 16:50