O'Reilly logo

Bootstrap for ASP.NET MVC by Pieter van der Westhuizen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Form layout and elements

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.

Horizontal 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", ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required