Generate bootstrap 4 styled alerts from html side or c# backend side.

Sample use cases of AlertTagHelper, based on bootstrap's alerts.


Install via nuget package manager,

            Install-Package LazZiya.TagHelpers
Then add LazZiya.TagHelpers to _ViewImports.cshtml
            @addTagHelper *, LazZiya.TagHelpers

C# backend generated alerts

            using LazZiya.TagHelpers.Alerts;

public class IndexModel : PageModel
    public void OnGet()
        TempData.Success("This is success alert message from c# backend!");

And on razor side we need to add one tag helper to render all alerts that is coming from backend:


Result :

Razor side generated alerts

<alert-primary>This is primary alert message!</alert-primary>
<alert-secondary>This is secondary alert message!</alert-secondary>
<alert-success>This is success alert message!</alert-success>
<alert-info>This is info alert message!</alert-info>
<alert-warning>This is warning alert message!</alert-warning>
<alert-danger>This is danger alert message!</alert-danger>
<alert-light>This is light alert message!</alert-light>
<alert-dark>This is dark alert message!</alert-dark>

Result :

Add header

<alert-success alert-heading="Yuppeeee!">This is success alert message with header!</alert-success>

Result :

Use html message

<alert-info alert-heading="LazZiya.TagHelpers">
    Read more about <a href="" class="alert-link">LazZiya.TagHelpers</a>.
    <p class="mb-0">© 2019</p>

Result :

Remove close button

<alert-primary dismissable="false">This alert has no close button!</alert-primary>

Result :