Use two CSS classes in C# Razor MVC

Asked

Viewed 463 times

1

I want to use two CSS classes in Razor. Is it possible to do this? Because I’m not getting it.

Here’s what I’m doing:

    <div class="form-group">
        @Html.LabelFor(model => model.ativo, htmlAttributes: new { @class = "control-label col-md-2", @id = "ativo" })
        <div class="col-md-10">
           @Html.CheckBoxFor(model => model.ativo, new { htmlAttributes = new { @class = "form-control flat" } })
            @Html.ValidationMessageFor(model => model.ativo, "", new { @class = "text-danger" })
        </div>
    </div>

But the stylization of the "flat" class does not work. Does anyone have any solution?

  • 1

    Are you sure the class isn’t being applied? Because that’s the way it’s done, if memory serves.

  • The way to assign the CSS classes in the component is correct, could post the class declaration flat kindly?

  • Lucas, you can’t forget to reference your style file. Something like <link href="~/Content/font-awesome.min.css" rel="stylesheet" />

No answers

Browser other questions tagged

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