Book Image

Bootstrap for ASP.NET MVC

By : Pieter van der Westhuizen
Book Image

Bootstrap for ASP.NET MVC

By: Pieter van der Westhuizen

Overview of this book

<p>Bootstrap, a leading open source frontend framework, takes care of typography, form layouts, and user interface components, allowing a developer to focus on writing code. Integrating ASP.NET's powerful components can further enhance its capabilities. This book guides you through the process of creating an ASP.NET MVC website from scratch using Bootstrap.</p> <p>You will learn about various Bootstrap components as well as techniques to include them in your own projects. The book includes practical examples to show you how to use open source plugins with Bootstrap and ASP.NET MVC and will guide you through building a website using Bootstrap, utilizing layout and user interface components. In the process, you will also learn to build HTML helpers and T4 templates as well as how to use the jQuery DataTables plugin. At the end of this book, you will find some valuable tips and tricks, which will help you in getting the most out of your Bootstrap and ASP.NET MVC integrated website.</p>
Table of Contents (18 chapters)
Bootstrap for ASP.NET MVC
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

The Bootstrap distribution


Before we can get started with Bootstrap, we first need to download its source files. At the time of writing this book, Bootstrap was at Version 3.1.1. You can download the latest version from http://getbootstrap.com.

The zip archive contains the following three folders:

  • css

  • fonts

  • js

Bootstrap style sheets (the css folder)

Do not be alarmed with the amount of files inside the css folder. This folder contains four .css files and two .map files. We would only need to include the bootstrap.css file in our project for the Bootstrap styles to be applied to our pages. The bootstrap.min.css file is simply a minified version of the aforementioned file.

The .map files can be ignored for the project we'll be creating. These files are used as a type of debug symbol (similar to the .pdb files in Visual Studio), which allow developers to live edit their preprocessor source files—something which is beyond the scope of this book.

Bootstrap fonts (the fonts folder)

Bootstrap uses Font Awesome to display various icons and glyphs in Bootstrap sites. Font Awesome was designed specifically for Bootstrap and the fonts folder contains the following four different formats of the font files:

  • Embedded OpenType (glyphicons-halflings-regular.eot)

  • Scalable Vector Graphics (glyphicons-halflings-regular.svg)

  • TrueType font (glyphicons-halflings-regular.ttf)

  • Web Open Font Format (glyphicons-halflings-regular.woff)

It is a good idea to include all these files in your web project as this will enable your site to display the fonts correctly in different browsers.

Note

The EOT font format is required for Internet Explorer 9 and newer. TTF is the traditional old font format and WOFF is a compressed form of TTF fonts. If you only need to support Internet Explorer 8 and later, iOS 4 and higher, as well as Android, you will only need to include the WOFF font.

Bootstrap JavaScript files (the js folder)

The js folder contains two files. All the Bootstrap plugins are contained in the bootstrap.js file. The bootstrap.min.js file is simply a minified version of the aforementioned file. Before including the file in your project, make sure that you have a reference to the jQuery library because all Bootstrap plugins require jQuery.

The default project template automatically adds the jQuery library to your project and creates a bundle for it. The jQuery bundle will be included in your pages if you have the following line of code inside your view:

@Scripts.Render("~/bundles/jquery")

Tip

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

The Bootstrap folder structure

The unzipped folder structure for Bootstrap will look something like the following screenshot: