Bootstrap for ASP.NET MVC - Second Edition - Pieter van der Westhuizen - E-Book

Bootstrap for ASP.NET MVC - Second Edition E-Book

Pieter van der Westhuizen

0,0
33,59 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

Combine the power of ASP.NET Core with Bootstrap 4 to build elegant, responsive web apps

About This Book

  • Updated for Bootstrap 4 and ASP.Net MVC 6, this book shows how to take advantage of the latest new features introduced in both of these industry-leading frameworks
  • Build responsive, mobile-ready apps by combining the power of ASP.NET MVC with Bootstrap
  • Grasp the intricacies of Bootstrap and how to use it with ASP.NET MVC
  • Build your own tools and helpers to assist you in creating ASP.NET MVC Bootstrap sites easily and quickly
  • Master the use of Bootstrap components and plugins with ASP.NET MVC

Who This Book Is For

If you are an ASP.NET MVC developer and would like to know how to incorporate Bootstrap into your projects, then this book is invaluable to you. Developers with entry-level experience of ASP.NET MVC development and limited experience with Bootstrap will also benefit from this book.

What You Will Learn

  • Create a new ASP.NET MVC project that uses Bootstrap for its styling and learn how to include external libraries using the new package managers
  • Learn to use the various Bootstrap CSS and HTML elements, and how to use the new Bootstrap 4 grid layout system
  • Explore the different input groups and implement alerts, progress bars, and badges
  • Explore JavaScript components by illustrating and walking through the process of using JavaScript/jQuery to add interactivity to Twitter Bootstrap components
  • Build your own ASP.NET MVC helpers and tag helpers to reduce the amount of HTML needed to generate Bootstrap elements
  • Convert a Bootstrap HTML template into a usable ASP.NET MVC project
  • Use the jQuery DataTables plugin with Bootstrap and ASP.NET MVC

In Detail

One of the leading open source frontend frameworks, Bootstrap has undergone a significant change and introduced several features that make designing compelling, next-generation UIs much simpler. Integrating Bootstrap with 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. After a primer on the fundamentals of Bootstrap, you will learn your way around and create a new ASP.NET MVC project in Visual Studio. You will move on to learn about the 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 guides you through building an ASP.NET MVC website using Bootstrap, utilizing layout and user-interface components. At the end of this book, you will find some valuable tips and tricks to help you get the most out of your Bootstrap-integrated and ASP.NET MVC-integrated website.

Style and approach

This is a compact, step-by-step guide that focuses on combining the power of Bootstrap with ASP.Net MVC to build next-generation web apps. With clear instructions, this book will show how to build a complete ASP.Net MVC-integrated web app from scratch using Bootstrap. It will also cover several tricks for integrating Bootstrap and ASP.Net MVC, and getting the most out of both frameworks.

Sie lesen das E-Book in den Legimi-Apps auf:

Android
iOS
von Legimi
zertifizierten E-Readern

Seitenzahl: 151

Veröffentlichungsjahr: 2016

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Table of Contents

Bootstrap for ASP.NET MVC Second Edition
Credits
About the Author
About the Reviewer
www.PacktPub.com
eBooks, discount offers, and more
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Getting Started with ASP.NET Core and Bootstrap 4
Files included in the Bootstrap distribution
Bootstrap style sheets
Bootstrap JavaScript files
Bootstrap fonts/icons
Bootstrap source files
CSS pre-processors
Creating an empty ASP.NET MVC site and adding Bootstrap manually
Enabling MVC and static files
Creating the default route controller and view
Adding the Bootstrap 4 files using Bower
Compiling the Bootstrap Sass files using Gulp
Adding Gulp npm packages
Enabling Gulp-Sass compilation
Running Gulp tasks
Binding Gulp tasks to Visual Studio events
Installing Font Awesome
Creating a MVC Layout page
Content Delivery Networks
Summary
2. Using Bootstrap CSS and HTML Elements
The Bootstrap grid system
Bootstrap Grid components
Containers
Rows
Columns
Bootstrap HTML elements
Bootstrap tables
Enabling MVC Scaffolding
Scaffolding an MVC List View page
Styling Bootstrap tables
Bootstrap contextual table classes
Responsive and smaller tables
Bootstrap buttons
Outline buttons
Form layout and elements
Vertical/basic forms
Inline forms
Grid-based forms
Bootstrap images
Bootstrap figures
Summary
3. Using Bootstrap Components
The Bootstrap navigation bar
Basic navbar
Responsive navbar
Navbar with dropdown menus
Navbar color schemes
List groups
Badges
Media object
Breadcrumbs
Pagination
Input groups
Button dropdowns
Alerts
Progress bars
Basic progress bar
Contextual progress bars
Striped and animated progress bars
Cards
Summary
4. Using Bootstrap JavaScript Components
Data attributes versus the programmatic API
Cascading dropdowns
Modal dialogs
Modal size and animation
Tabs
Tooltips
Popovers
The accordion/collapse component
The carousel component
Summary
5. Creating MVC Bootstrap Helper and Tag Helpers
Built-in HTML Helpers
Built-in Tag Helpers
The difference between HTML Helpers and Tag Helpers
Creating HTML Helpers using static methods
Using the static method helper in a view
Creating helpers using extension methods
Using the extension method helper in a view
Creating self-closing helpers
Using the self-closing helper in a view
Creating a Bootstrap button Tag Helper
Using the Bootstrap button Tag Helper
Creating a Bootstrap Alert Tag Helper
Using the Bootstrap Alert Tag Helper
Summary
6. Converting a Bootstrap HTML Template into a Usable ASP.NET MVC Project
Working with prebuilt HTML templates
Creating the ASP.NET MVC project
Creating the master layout
Adding a view for the home controller
Adding different page views
Adding charts to views
Adding Google Charts to views
Server-side data processing with Google Charts
Summary
7. Using the jQuery DataTables Plugin with Bootstrap 4
jQuery DataTables
Adding DataTables to your ASP.NET MVC project
Using the DataTables Bower package
Using the CDN
Adding Bootstrap styling to DataTables
Loading and displaying data in jQuery DataTables
DataTables plugins
Date sorting
Rendering
DataTables extensions
The ColReorder extension
The ColVis buttons extension
The copy and print buttons extension
Summary
8. Creating Bootstrap 4 ASP.NET MVC Sites Using Visual Studio Code
What is Visual Studio Code?
Installing Visual Studio Code
Creating an empty ASP.NET project
Scaffolding a project using Yeoman
Enabling ASP.NET MVC and static files
Adding a default route controller and view
Using Bower to add the Bootstrap 4 files
Using Gulp to compile the Bootstrap Sass files
Creating a MVC layout page
Testing the site
Summary
A. Bootstrap Resources
Themes
Add-ons
Editors and generators

Bootstrap for ASP.NET MVC Second Edition

Bootstrap for ASP.NET MVC Second Edition

Copyright © 2016 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

First published: August 2014

Second edition: September 2016

Production reference: 1270916

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham 

B3 2PB, UK.

ISBN 978-1-78588-947-9

www.packtpub.com

Credits

Author

Pieter van der Westhuizen

Copy Editor

Safis Editing

Reviewer

Dony Perdana

Project Coordinator

Devanshi Doshi

Acquisition Editor

Reshma Raman

Proofreader

Safis Editing

Content Development Editor

Samantha Gonsalves

Indexer

Tejal Soni

Technical Editor

Jayesh Sonawane

Graphics

Jason Monteiro

Production Coordinator

Arvindkumar Gupta

About the Author

Pieter van der Westhuizen is a freelance software and web developer specializing in ASP.NET MVC, web technologies, and MS Office development. He started his career in web development using classic ASP, Visual InterDev, HoTMetaL, and FrontPage. Pieter has over 16 years of experience in the IT industry and is also one of the people fortunate enough to have his hobby become his full-time profession.

He is also a technology evangelist for Add-in Express (www.add-in-express.com), which focuses on tools for Microsoft Office integration.

This is Pieter's second book and he has been blogging since 2007 on his personal blog at www.mythicalmanmoth.com and on the Add-in Express blog since 2010. He lives with his wife and two dogs in Pretoria, South Africa.

To everyone who contributed to this book, thank you! A big thanks to the team at Packt Publishing, for their guidance, advice, and professionalism. Thanks to my technical reviewer, Dony Perdana, for patiently reading each chapter, reviewing each line of code, and contributing suggestions. You helped shape this book into what it is. I'd like to express my greatest love and gratitude towards my wife, Andrea, for all her support, impromptu editing sessions, being a soundboard for brainstorming sessions, and the general motivational pep talks during the writing of this book. Lastly, thanks to you for buying this book. I hope this can help you become a better programmer. If you have any questions regarding this book, please visit www.bootstrapforaspnetmvc.com.

About the Reviewer

Dony Perdana is an enthusiast and full-stack .NET developer from Indonesia. He has been involved with various banking project solutions for the past 5 years, especially on .NET server side web technologies such as ASP Web API, ASP MVC, ASP Core 1.0, and ServiceStack. He is also proficient with frontend web development, including various JavaScript frameworks (JQuery, AngularJS, BackboneJS, KnockoutJS, and ReactJS).

He developed many applications, including content management systems, real-time and scheduler application, social media apps, web service-based applications.

He has strongly believes that design-pattern practices and agile development can tackle any problem and increase team productivity in software development.

In his spare time, he participates in many learning resources such as reading books, chess, and going to conferences and meetups to keep up with the latest technologies and methodologies for programming. He also helps people on Stack Overflow and contributes to opensource projects on GitHub repositories.

www.PacktPub.com

eBooks, discount offers, and more

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.

https://www.packtpub.com/mapt

Get the most in-demand software skills with Mapt. Mapt gives you full access to all Packt books and video courses, as well as industry-leading tools to help you plan your personal development and advance your career.

Why subscribe?

Fully searchable across every book published by PacktCopy and paste, print, and bookmark contentOn demand and accessible via a web browser

Preface

Twitter Bootstrap, known simply as Bootstrap, is the leading open source CSS/HTML and JavaScript framework on the Internet. Shortly after its launch, it was the most popular project on GitHub. It is so popular that Microsoft announced at their Build 2013 conference that all the web app project templates in Visual Studio 2013 will use Twitter Bootstrap by default.

One of the main reasons Bootstrap is so prevalent is that it allows developers, many of whom are notoriously bad at user interface design, to build aesthetically pleasing sites with a relatively small amount of effort. Bootstrap also offers a rich ecosystem of free and commercial templates, third-party components, tools, and an active and helpful community.

Using CSS Frameworks and Bootstrap in particular with ASP.NET MVC is a natural fit. Bootstrap takes care of the typography, form layouts, and user interface components, which allows the developer to focus on what they are good at – writing code.  This aspect is particularly valuable for smaller development companies who do not necessarily have an in-house designer.

.NET Core is a new and exciting framework written from the ground up. It can be used to develop a variety of applications, not just web applications. It promises the ability to target different platform, such as Linux and Mac as well as smaller deployment footprints. ASP.NET Core has been built upon the .NET Core and is a rewrite of the ASP.NET platform .NET developers have known for many years.

What this book covers

Bootstrap for ASP.NET MVC walks you through the process of creating a fully functioning ASP.NET MVC website, using Bootstrap for its layout and user interface.

Chapter 1, Getting Started with ASP.NET Core and Bootstrap 4, introduces you to the files in the Bootstrap 4 distribution, creating an empty ASP.NET site as well as providing an introduction to using Bower and Gulp.

Chapter 2, Using Bootstrap CSS and HTML Elements, examines all the various Bootstrap CSS and HTML elements, how to include them in your ASP.NET MVC project, and how to configure and use their various options.

Chapter 3, Using Bootstrap Components, makes you familiar with the Bootstrap navigation bar, button groups, alerts, and introduces you to cards.

Chapter 4, Using Bootstrap JavaScript Components, guides you through creating cascading dropdowns, modal dialogs and accordions.

Chapter 5, Creating MVC Bootstrap Helper and Tag Helpers, teaches you to create a Bootstrap MVC helper as well as a Tag Helper introduced with ASP.NET Core.

Chapter 6, Converting a Bootstrap HTML Template into a Usable ASP.NET MVC Project, converts an open source HTML template and makes it ready to be used with ASP.NET MVC.

Chapter 7, Using the jQuery DataTables Plugin with Bootstrap 4, demonstrates how to use the powerful jQuery DataTables plugin with Bootstrap and ASP.NET in order to show tabular data.

Chapter 8, Creating Bootstrap 4 ASP.NET MVC Sites Using Visual Studio Code, shows you how to use the free Visual Studio Code editor to create ASP.NET projects.

Appendix, Bootstrap Resources, gives you a list of Bootstrap resources available on the Internet.

What you need for this book

To get the most out of this book, you’ll need Visual Studio 2015 and a modern browser. All examples have been tested with Visual Studio 2015, Google Chrome, and Mozilla Firefox. The book would be beneficial to those with entry-level up to advanced-level experience of ASP.NET MVC development, as well as limited experience in Bootstrap.

Who this book is for

This book is for ASP.NET MVC developers who would like to know how to incorporate Bootstrap into their projects. ASP.NET MVC developers could also benefit from the chapters covering advanced topics, such as creating helpers and using the jQuery Data-tables plugin. If you have limited experience with ASP.NET MVC and Bootstrap, this book can serve as a primer to these technologies.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Double-click on the project.json file inside the Solution Explorer in Visual Studio"

A block of code is set as follows:

public void ConfigureServices(IServiceCollection services) { services.AddMvc(); }

Any command-line input or output is written as follows:

npm install -g yo grunt-cli generator-aspnet bower

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Select the Empty project template from the New ASP.NET Core Web Application (.NET Core) Project dialog window and click on OK"

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book-what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of. To send us general feedback, simply e-mail [email protected], and mention the book's title in the subject of your message. If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book from https://github.com/Pietervdw/bootstrap-for-aspnetmvc or 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.

You can download the code files by following these steps:

Log in or register to our website using your e-mail address and password.Hover the mouse pointer on the SUPPORT tab at the top.Click on Code Downloads & Errata.Enter the name of the book in the Search box.Select the book for which you're looking to download the code files.Choose from the drop-down menu where you purchased this book from.Click on Code Download.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

WinRAR / 7-Zip for WindowsZipeg / iZip / UnRarX for Mac7-Zip / PeaZip for Linux

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from http://www.packtpub.com/sites/default/files/downloads/BootstrapforASPNETMVC_ColorImages.pdf.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at [email protected] with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.

Chapter 1. Getting Started with ASP.NET Core and Bootstrap 4

As developers, we can find it difficult to create great-looking user interfaces from scratch when using HTML and CSS. This is especially hard when developers have extensive experience developing Windows Forms applications. Microsoft introduced Web Forms to remove the complexities of building websites and to ease the switch from Windows Forms to the Web. This in turn makes it very hard for Web Forms developers, and even harder for Windows Forms developers, to switch to ASP.NET MVC. Bootstrap is a set of stylized components, plugins, and a layout grid that takes care of the heavy lifting. Microsoft has included Bootstrap in all ASP.NET MVC project templates since 2013.

In this chapter, we will cover the following topics:

Files included in the Bootstrap distributionHow to create an empty ASP.NET site and enable MVC and static filesAdding the Bootstrap files using BowerAutomatically compile the Bootstrap Sass files using GulpInstalling additional icon setsHow to create a Layout file that references the Bootstrap files

Files included in the Bootstrap distribution

In order to get acquainted with the files inside the Bootstrap distribution, you need to download its source files. At the time of writing, Bootstrap 4 was still in Alpha, and its source files can be downloaded from http://v4-alpha.getbootstrap.com.

Bootstrap style sheets