Creating a Bootstrap button Tag Helper
Tag Helpers are a new addition to ASP.NET MVC Core and can be used to generate HTML markup. The syntax of Tag Helpers is similar to traditional HTML elements, but is still processed on the server.
Although traditional HTML Helpers are still available, Tag Helpers are intended as an alternative, if not replacement, syntax.
To create your own custom Tag Helper that will generate a Bootstrap button, complete the following steps:
- Add a new folder called
TagHelpers
to your project. - Create a new class called
BootstrapButtonTagHelper
in theTagHelpers
folder. - Change the
BootstrapButtonTagHelper
to inherit from theTagHelper
class, which is a built-in class of theMicrosoft.AspNetCore.Razor.TagHelpers
package. - In order ...
Get Bootstrap for ASP.NET MVC - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.