-
Book Overview & Buying
-
Table Of Contents
Bootstrap for ASP.NET MVC - Second Edition
By :
Self-closing helpers are helpers that can contain HTML and Razor markup. The built-in @Html.BeginForm() helper is an example of this helper type.
In order to create this type of HTML Helper, we'll need to create a helper class that implements the IDisposable interface. Using the IDisposable interface, we can write the element's closing tags when the object is disposed.
The Bootstrap Alert component is a good candidate for such a helper. To create the helper, we'll have to complete the following steps:
Create a new subfolder called Alerts inside the Helpers folder in your project.
Open the Enums.cs file and add a new item called AlertStyle:
public enum AlertStyle
{
Default,
Primary,
Success,
Info,
Warning,
Danger
}
Add a new class file called Alert.cs to the Alerts folder.
Add a new private, read-only TextWriter object field to the class called _writer:
private...
Change the font size
Change margin width
Change background colour