Skip to content
This repository has been archived by the owner on Mar 7, 2020. It is now read-only.

Vassi/MvcFlash

 
 

Repository files navigation

Flash Messaging for ASP .NET MVC 3

Inspired by the “rails flash”

There are times where you would like to pass a message up to the view, but you aren’t sure where the redirects will end up last. That is where MvcFlash comes in. You push messages into MvcFlash and then call Flash() when you need the messages to appear. A super simple implementation that just work.Download the source and run the sample to see all the things you can do

In The Controller

Flash.Notice("Hey, what's up?")
Flash.Error("oh no!");
Flash.Warning("sucks");
Flash.Success("WooHoo!");
Flash.Push(new {CrazyProperty = "I'm a mad man!"});

In The View
// In The Razor View
// Simple Flash
@Html.Flash()	// Flash everything, default template: "Flash"
@Html.Flash("MyOwnTemplate") // Flash evertying, custom template
@Html.Flash((ctx) => Html.Partial("Flash", ctx)) // Flash everything, lambda
// Flash Only
@Html.FlashOnly("success") // pass in the type
@Html.FlashOnly(new [] {"success", "error"}) // pass in many types
@Html.FlashOnly(x => x.Type == "success" || x.Type == "error") // pass in a lambda
// Flash Select
@Html.FlashSelect("success") // pass in the type, default template: "Flash"
@Html.FlashSelect(x => x.Type == "success") // pass in a lambda
@Html.FlashSelect("success", "template") // pass in the type filter, and the template name	
@Html.FlashSelect(x => x.Type == "success", (ctx) => Html.Partial("Flash", ctx) ) // pass in a lambda

The Template
@model MvcFlash.Core.Models.FlashContext
<div id="@[email protected]" class="@Model.Message.Type">@Model.Message.Text</div>

Contributors

Written by Khalid Abuhakmeh

About

Flash Messages inspired by Rails

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published