Forms make up a large section of most line-of-business applications; and therefore, applying a uniform style to all forms in your web application is not only visually pleasing but also provides your users with a friendlier interface. Bootstrap provides a range of CSS styles to enable you to create visually appealing forms.
The default create and edit templates for ASP.NET MVC scaffolding generate horizontal-styled Bootstrap forms. This is accomplished by automatically adding the form-horizontal
class name to the <form>
element. In the following code example, a horizontal login form is created using the Html.BeginForm
helper method; this form contains two textboxes and a submit
button:
@using (Html.BeginForm("Login", "Account", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{
<div class="form-group">
@Html.LabelFor(m => m.UserName, new { @class = "col-md-2 control-label" })
<div class="col-md...