Alert TagHelpers

Create clean bootstrap alerts from backend or front end code using Alert TagHelpers for Asp.Net Core projects


Install via nuget :

Install-Package LazZiya.TagHelpers -Version 2.2.0

add tag helper to _ViewImports.cshtml:

@addTagHelper *, LazZiya.TagHelpers


Easily create bootstrap 4.x alerts from c# backend or razor pages using html codes. All bootstrap alerts can be created from both ends (Primary, Secondary, Success, Info, Warning, Danger, Light, Dark).

Create alert from razor page using HTML

<alert-success>Congratulations! you have done the job!</alert-success>


Create alert from c# backend

Alert are TempData items, so they will be disposed once they are fetched. You can create alerts from the c# backend by the provided extension methods for TempData as below:

using LazZiya.TagHelpers.Alerts

TempData.Danger("Ooopps! something went wrong with the code, please contact support.");

Then use the alert taghelper to render the relevant alerts on html side:

<alert view-context="ViewContext"></alert>


Alert Properties

For HTML side generated alerts all properties are optional, only message is required between alert tags.

 - alert-header: add header text to the alert 

 - dismissable: bool value to show close button (true by default)


For c# backend generated alerts, only one parameter is required (view-context="ViewContext") in order to access the views' TempData dictiaonary that contains the alert messages.


Live demos

See live demos :

GitHub Repository

See GitHub repo: