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 .…