Can Bootstrap be used in a form made with Razor in MVC?

0

I made a form in one of the View of my project, and now I want to apply Bootstrap to give it style, is it possible to do it?

I tried it this way but without results:

<form class="form-horizontal">

<label>Nombre</label>
@Html.TextBoxFor(x => x.NombreUsuario)
<br />

<label>Direccion</label><br />
@Html.TextBoxFor(x => x.Direccion)
<br /> 

<label>Telefono</label><br />
@Html.TextBoxFor(x => x.Telefono)
<br />

<label>Email</label><br />
@Html.TextBoxFor(x => x.Email)
<br />

</form>

UPDATE

I was able to do it, and now I would like to use the class form-horizontal of Bootstrap. My code is as follows:

@using (Html.BeginForm("Guardar", "Usuario", FormMethod.Post))
{

    @Html.HiddenFor(x => x.IdUsuario)

    <label>Nombre</label><br />
    @Html.TextBoxFor(x => x.NombreUsuario, new { @class = "form-control" })
    <br />

    <label>Contrasena</label><br />
    @Html.TextBoxFor(x => x.Contrasena, new { @class = "form-control" })
    <br />

    <label>Direccion</label><br />
    @Html.TextBoxFor(x => x.Direccion, new { @class = "form-control" })
    <br />

    <label>Telefono</label><br />
    @Html.TextBoxFor(x => x.Telefono, new { @class = "form-control" })
    <br />

    <label>Email</label><br />
    @Html.TextBoxFor(x => x.Email, new { @class = "form-control" })
    <br />

}

Adding it in this way new {@class = "form-horizontal form-control"} does not work, and also not in this way <form class = "form-horizontal"></form>

    
asked by Akiva 07.03.2016 в 23:14
source

1 answer

1

Yes it is possible, if you mean to add styles try this:

 @Html.TextBoxFor(m => m.NombreUsuario, new { @class = "AquiElEstiloQueDeseasAgregar" })

Edited

Adding styles to your form:

@using (Html.BeginForm("Guardar", "Usuario", FormMethod.Post, new { @class = "form-horizontal" }))
    
answered by 07.03.2016 / 23:24
source