Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Flash Messages inspired by Rails
C# JavaScript Other
branch: master

Merge pull request #6 from TechplexEngineer/patch-1

Make it easier to figure out what import statements are needed
Failed to load latest commit information.
MvcFlash.Core changed Flash.Count() to Flash.Count
MvcFlash.Sample made unique feature, and added attributes.
MvcFlash.Tests changed Flash.Count() to Flash.Count
packages
.gitignore added ignore to nupkg
MIT-LICENSE.txt setup solution and projects.
MvcFlash.nuspec updated nuspec again.'
MvcFlash.sln setup solution and projects.
README.textile Make it easier to figure out what import statements are needed
README.txt fixed and tested redirect, new SessionFlashMessageService. HttpContex…
icon.png updated nuspec and icon.png added.
web.config.transform

README.textile

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

//Be sure to include these
using MvcFlash.Core;
using MvcFlash.Core.Filters;
//
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="@Model.Message.Type-@Model.Index" class="@Model.Message.Type">@Model.Message.Text</div>

Contributors

Written by Khalid Abuhakmeh

Something went wrong with that request. Please try again.