I recently released a project I kept internally into the wild. This is a plugin has been hugely successful (personally) and the feedback given to the users is incomparable. There’s no more excuses for us developers in not giving our users the best possibly experience(s) they can have with our products. Thus, I introduce NotyMVC; a simple little library that integrates the notorious jQuery Noty with ASP.NET MVC’s framework. As a developer I simply use the provided extension methods or the javascript method to produce a jQuery Noty notification.
ASP.NET MVC
After adding the Nuget Package, you’ll notice in the root Views\Shared folder there is a new file named “NotyNotifications.cshtml”. This is the entry point we use to create the notification bubble. What you need to do is add this to your preferred (~\Views\Shared\Layout.cshtml, aka “Master Page”), using @Html.Partial(“NotyNotifications”);
Then from your controller actions you’ll simply use an extension method to create the notifications. For example,
public ActionResult Contact(ContactViewModel model) { ... return View(model).WithNotification("There seems to be an error", alertType: AlertType.error); // OR return RedirectToAction("Index").WithNotification("Thank you for contacting.."); }
The extension works off ActionResult, so any redirect, view return, or new type (derived from ActionResult) that comes out will work with this extension.
Think of another use for this or something similar? Contribute to the GitHub code here!
Till next time,
Have a great day!