Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've written an example of Rails style Flash messages for ASP.NET using cookies and JavaScript on the client, with source code &amp; example.</p> <ul> <li><a href="http://10consulting.com/2011/08/29/asp-dot-net-mvc-flash-messages-with-razor-view-engine/" rel="nofollow">Rails-style "flash" messages for ASP.NET MVC with Razor view templates</a></li> <li><a href="https://gist.github.com/d333bcf22ca167aa7f01" rel="nofollow">Source code</a> (gist.github.com)</li> </ul> <p><strong>Usage</strong></p> <p>Add a reference to the two JavaScript files: <code>jquery.cookie.js</code> (standard jQuery cookie plugin) and <code>jQuery.flashMessage.js</code></p> <p>Reference the <code>_Flash.cshtml</code> partial within your main layout view. This will determine where the flash messages appear.</p> <pre><code>@Html.Partial("_Flash") </code></pre> <p>Add the <code>FlashMessageExtensions.cs</code> static extension method class to your website.</p> <p>Within your MVC controllers simply use the <code>.Success("message to show")</code> and the corresponding <code>Error</code>, <code>Warning</code> or <code>Information</code> extension methods on <code>ActionResult</code> to set the flash cookie on the response. Remember to add the necessary using statement to use these methods from flash extension class above.</p> <pre><code>[HttpPost] public ActionResult Create() { return RedirectToAction("Index").Success("Message shown to user after redirect"); } </code></pre> <p>By default the flash message will fade out after 3 seconds or if the user clicks on it. The fade-out delay is configurable by setting the timeout option when configuring the JavaScript flash plugin, or can be disabled be setting it to 0.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload