Giter Site home page Giter Site logo

ariejones / flashmessage Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vereyon/flashmessage

0.0 2.0 0.0 955 KB

FlashMessage provides easy cross request notifications for ASP.NET MVC based on Twitter Bootstrap alerts.

License: MIT License

C# 85.53% HTML 7.07% JavaScript 6.59% CSS 0.75% ASP 0.07%

flashmessage's Introduction

FlashMessage

NuGet version

FlashMessage provides easy cross request notifications for ASP.NET MVC based on Twitter Bootstrap. It solves the problem with flashing the user a notification or message when using the Post/Redirect/Get pattern and RedirectToAction() method.

Usage

Install the FlashMessage NuGet package and import the Vereyon.Web namespace where you need it.

Rendering flash messages

Typically you want to render all queued flash messages in your Layout Razor template using the following code:

@Html.RenderFlashMessages()

Queuing flash messages

Queuing a confirmation message for display on the next request after for example user login is done as follows:

// User successfully logged in
FlashMessage.Confirmation("You have been logged in as: {0}", user.Name);
return RedirectToLocal(returnUrl);

Different types of messages can be scheduled using different static methods on the FlashMessage object:

FlashMessage.Info("Your informational message");
FlashMessage.Confirmation("Your confirmation message");
FlashMessage.Warning("Your warning message");
FlashMessage.Danger("Your danger alert");
FlashMessage.Danger("Message title", "Your danger alert");

Advanced options

Using the FlashMessage.Queue() method advanced options are available:

FlashMessage.Queue(string.Format("You have been logged in as: {0}", user.Name), "Title", FlashMessageType.Confirmation, false);

The FlashMessage class allows you to queue messages anywhere in your code where a HttpContext is available and the response has not yet been sent out. You can thus also use FlashMessage outside your MVC actions or with WebForms applications.

Tests

Got tests? Yes, see the tests project. It uses xUnit.

More information

License

MIT X11

flashmessage's People

Contributors

cakkermans avatar larikitty avatar odai-massar avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.