Menu

1 / 2

ASP .NET Core Bootstrap toast

DEV Community: aspnet·Karen Payne·5 months ago
#Oqk4BqdL
Reading 0:00
15s threshold

Introduction

Bootstrap toasts are lightweight notifications that mimic the push notifications popularized by mobile and desktop operating systems.

Learn how to merge C# code into toast to make toast flexible.

Source code net10

Get coding

Toast options for demonstration are read from appsettings.json, while toast options may be hard-coded in code.

{ "Logging" : { "LogLevel" : { "Default" : "Information" , "Microsoft.AspNetCore" : "Warning" } }, "AllowedHosts" : "*" , "ToastOptions" : { "DatabaseError" : { "ToastMessage" : "Failed to open database!" , "ToastTitle" : "Error" , "ToastDelay" : 10000 } } }

Enter fullscreen mode

Exit fullscreen mode

In the above ToastOptions has DatabaseError item which allows you to have multiple toast configurations.

These classes are used to parse the json above.

public class ToastOptions { public ToastMessageOptions DatabaseError { get ; set ; } = new (); }

public class ToastMessageOptions { public string ToastMessage { get ; set ; } = string .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.