Migrating an existing ASP.NET MVC project to ASP.NET Core MVC, and there are no ajax tag helpers?
The tag helpers have been replaced with data-ajax-*** attributes.
To use ajax, you'll need to reference jquery and jquery.unobtrusive-ajax scripts, you can download and install it via npm, libman, etc. Here is a CDN link (https://cdnjs.com/libraries/jquery-ajax-unobtrusive).
Once you install ajax, add a reference in _layout.cshtml, for example:
<script src="~/lib/jquery-unobtrusive/jquery.unobtrusive-ajax.min.js"></script>
or
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-ajax-unobtrusive/3.2.6/jquery.unobtrusive-ajax.min.js"></script>
Here are the @Ajax tag helpers and their html attributes equivalents.
| Ajax Option | HTML attribute |
|---|---|
| Confirm | data-ajax-confirm |
| HttpMethod | data-ajax-method |
| InsertionMode | data-ajax-mode |
| LoadingElementDuration | data-ajax-loading-duration |
| LoadingElementId | data-ajax-loading |
| OnBegin | data-ajax-begin |
| OnComplete | data-ajax-complete |
| OnFailure | data-ajax-failure |
| OnSuccess | data-ajax-success |
| UpdateTargetId | data-ajax-update |
| Url | data-ajax-url |
Discussion (0)
Community Guidelines EnforcedNo community comments yet. Be the first to share your thoughts!
Join the Community Discussion
Sign in or create an account to share observations, tuning setups, and connect with other makers.