September 24, 2017 by Anuraj
ASP.NET Core JQuery Unobtrusive
This post is about getting jQuery Unobtrusive Ajax helpers in ASP.NET Core. AjaxHelper Class represents support for rendering HTML in AJAX scenarios within a view. If you’re migrating your existing ASP.NET MVC project to ASP.NET Core MVC, but there is no tag helpers available out of the box as replacement. Instead ASP.NET Core team recommends
data-* attributes. All the existing
@Ajax.Form attributes are available as
To use this first, you need to reference
jquery.unobtrusive-ajax scripts, you can download and install it via bower. Here is the command to install the script libraries via bower -
bower install Microsoft.jQuery.Unobtrusive.Ajax.
Once you install the script, you can reference it in
_layout.cshtml file like this.
Here is the attributes which can be used to migrate
You can add these attributes with the Form element like this.
Here is the code, which will display a progress indicator while submitting the form, and once it is completed, success or failed, it will show alert message.
And here is the HTML form.
Happy Programming :)
Copyright © 2024 Anuraj. Blog content licensed under the Creative Commons CC BY 2.5 | Unless otherwise stated or granted, code samples licensed under the MIT license. This is a personal blog. The opinions expressed here represent my own and not those of my employer. Powered by Jekyll. Hosted with ❤ by GitHub