Skip to content

Add Rails-like flash functionality to your ASP.NET MVC controllers.

License

Notifications You must be signed in to change notification settings

oziriz31/mvc-toastr-flash

 
 

Repository files navigation

MVC Toastr Flash

This package adds Rails-like flash functionality to your MVC controllers, backed by the excellent Toastr JavaScript notification library. Flash notifications are persisted through redirects and are removed when shown.

Install

Best way to install is via NuGet:

PM> Install-Package RedWillow.MvcToastrFlash

This package has the following NuGet dependencies:

Usage

First, follow the steps required to get Toastr up and working: https://www.nuget.org/packages/toastr

Layouts / Views

At the top of your layouts pages, or views that don't use layouts (that you want Toastr notifications to appear on) add:

@using RedWillow.MvcToastrFlash

And following the @RenderSection("scripts", required: false) near the bottom add (should be right before the closing body tag):

@Html.ToastrNotifications()

Controllers

Add this using statement:

using RedWillow.MvcToastrFlash;

Then, flash notifications to your heart's content:

public ActionResult Index()
{
    this.Flash(Toastr.SUCCESS, "Welcome!", "Glad you arrived safely.");

    return View();
}

See the Sample project for more usage examples.

License

The MVC Toastr Flash package is released under a MIT license

About

Add Rails-like flash functionality to your ASP.NET MVC controllers.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 72.2%
  • C# 16.2%
  • CSS 9.3%
  • HTML 2.3%