UoN.AspNetCore.FeedbackMessage
1.1.0
See the version list below for details.
dotnet add package UoN.AspNetCore.FeedbackMessage --version 1.1.0
NuGet\Install-Package UoN.AspNetCore.FeedbackMessage -Version 1.1.0
<PackageReference Include="UoN.AspNetCore.FeedbackMessage" Version="1.1.0" />
paket add UoN.AspNetCore.FeedbackMessage --version 1.1.0
#r "nuget: UoN.AspNetCore.FeedbackMessage, 1.1.0"
// Install UoN.AspNetCore.FeedbackMessage as a Cake Addin #addin nuget:?package=UoN.AspNetCore.FeedbackMessage&version=1.1.0 // Install UoN.AspNetCore.FeedbackMessage as a Cake Tool #tool nuget:?package=UoN.AspNetCore.FeedbackMessage&version=1.1.0
UoN.AspNetCore.FeedbackMessage
What is it?
Reusable bits for ASP.NET Core to make displaying feedback messages after action redirects easy.
What are its features?
It provides the following:
- An enum of Bootstrap 4 based Alert Types
- A model class representing a Feedback Message
- Extension methods for setting and getting
FeedbackMessageModel
s atTempData["FeedbackMessage"]
- A TagHelper for rendering any Feedback Message at
TempData["FeedbackMessage"]
- A Controller for returning a partial view (constructed by the TagHelper); useful for requesting via AJAX to add to a page.
- An extension method for adding the controller (and partial view) to MVC.
Dependencies
The library targets netstandard2.0
and depends upon ASP.Net Core 2.0 MVC.
If you can use ASP.Net Core 2 MVC, you can use this library.
Usage
Acquiring the library
NuGet
This library is available from nuget.org
Build from source
We recommend building with the dotnet
cli, but since the package targets netstandard2.0
and depends only on ASP.Net Core 2.0 MVC, you should be able to build it in any tooling that supports those requirements.
- Have the .NET Core SDK 2.0 or newer
dotnet build
- Optionally
dotnet pack
- Reference the resulting assembly, or NuGet package.
Standard Server-side usage
- Acquire the library via one of the methods above.
- Use
this.SetFeedbackMessage()
inside an MVC Controller method. - Import TagHelpers from this assembly
- add the following to a Razor View, or to
_ViewImports.cshtml
: @addTagHelper *, UoN.AspNetCore.FeedbackMessage
- add the following to a Razor View, or to
- Use the
<uon-feedbackmessage />
TagHelper in a a Razor View. - ????
- PROFIT!
An example:
MyController.cs
public class MyController : Controller
{
...
public IActionResult MyAction()
{
this.SetFeedbackMessage("Hello!", AlertTypes.Info);
return View();
}
}
MyAction.cshtml
<div>
<uon-feedbackmessage />
The rest of my HTML content is here and very interesting.
</div>
- If a Feedback Message is not set,
<uon-feedbackmessage />
will simply collapse into nothing. - If a Feedback Message is set,
<uon-feedbackmessage />
will turn into something like the following:
<div class="alert alert-info">
Hello!
</div>
AJAX usage
- Acquire the library via one of the methods above.
- Use
services.AddMvc().AddAjaxFeedbackMessageSupport()
insideStartup.ConfigureServices()
- Optionally specify an MVC Route template for the
FeedbackMessageAjaxController
, else it will default to/FeedbackMessageAjax
as per MVC default conventions - Write some javascript that makes an AJAX request, and puts the result onto the page.
- ????
- PROFIT!
An example:
Startup.cs
public void ConfigureServices(IServiceCollection services)
{
...
services.AddMvc()
.AddAjaxFeedbackMessageSupport(services);
...
}
feedback-message.js
//global function that assumes we have jquery...
window.feedbackMessage = (message, type) => {
let feedback = $("#feedback-message"); //this is a div on the page
$.get({
url: "/FeedbackMessageAjax",
data: { "message": message, "type": type },
success: function(content) {
//use animation to make it clear the message has changed if there was already one there!
feedback.fadeOut(200, "swing", function() {
feedback.html(content);
feedback.fadeIn(100);
});
}
});
};
...
//some situation in which we want a feedback message
window.feedbackMessage("Hello!", "info");
Contributing
Contributions are welcome.
If there are issues open, please feel free to make pull requests for them, and they will be reviewed.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.AspNetCore.Mvc (>= 2.0.0)
- Microsoft.Extensions.FileProviders.Embedded (>= 2.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
This release features AJAX support:
- A Controller and Partial View that can be used to get feedback message html via ajax
- An `IMvcBuilder` extension for registering the aforementioned controller from this assembly.