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

Customizing the generated code for views


As with controllers, the scaffolding for views can also be customized. In our example project used throughout this book, our views followed a consistent look. Each page has a page header followed by a breadcrumb component to indicate to the user which page is currently being viewed.

We always want to follow this design when adding a new page to our site, and one method of enforcing this is to either override the default scaffolder for views or add our own. We'll create a T4 template that will generate a standard, vertical Bootstrap form that already contains a page header and a breadcrumb component. To accomplish this, perform the following steps:

  1. Open the MvcView folder inside the CodeTemplates folder.

  2. Right-click on the Create.cs.t4 file and select Copy.

  3. Right-click on the MvcView folder and select Paste.

  4. The file will be copied as Create.cs – Copy.t4; rename it to VerticalForm-Bootstrap.cs.t4.

  5. Double-click on VerticalForm-Bootstrap.cs.t4 to open it.

  6. Add...