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

Adding Bootstrap files using NuGet


So far we've created two ASP.NET MVC projects that use the Bootstrap frontend framework. The first included the Bootstrap assets by default because we created it with the standard ASP.NET MVC Visual Studio project template. The second, we created an empty ASP.NET MVC project and added the Bootstrap files manually.

NuGet is a package manager for the .NET framework and can be used to automatically add files and references to your Visual Studio projects. A Bootstrap package exists on the NuGet gallery site, which enables you to automatically add the Bootstrap assets to your project.

Bear in mind that though the Bootstrap NuGet package assumes that you want your Bootstrap files in the Content and Scripts folders and will create the folders and files as such, it will also automatically check whether you have the jQuery library referenced and if not, add it by design.

Tip

NuGet is a package manager for the Microsoft development platform that makes it easy to add references to existing libraries. You can read more about it on https://www.nuget.org/.

Adding the Bootstrap NuGet package using the dialog

One option for adding the Bootstrap NuGet package to your project is to use the Manage NuGet Packages dialog box. To access the Manage NuGet Packages dialog and add the Bootstrap NuGet package, perform the following steps:

  1. Right-click on the References node in the Solution Explorer section and select Manage NuGet Packages. Click on the Online tab and type bootstrap in the search box and press Enter, as shown in the following screenshot:

  2. Click on the Install button to add the Bootstrap files to your project.

Adding the Bootstrap NuGet package using the Package Manager Console

The second method of adding NuGet packages to your Visual Studio project is via the Package Manager Console and completing the following steps:

  1. Inside Visual Studio, from the Tools menu, navigate to Library Package Manager | Package Manager Console. This will open the Package Manager Console window.

  2. To install the Bootstrap NuGet packages, type Install-Package bootstrap, as shown in the following screenshot:

  3. This will create the Content, fonts, and Scripts folders and add the necessary Bootstrap files to each.