Skip to content

NimeshDhruve/Asp.NetCoreAJAX

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Asp.NetCoreAJAX

Demo of how to make AJAX call in Asp.Net Core 2 using razor pages

To get AJAX calls working like previous versions of MVC, you would need jQuery Unobtrusive Ajax

Once the js file is included in your code, you can use data-ajax* attributes to make ajax call

<script src="~/js/jquery.unobtrusive-ajax.js"></script>

Example:

<form action="/Time" method="get"
              data-ajax-update="#Results" data-ajax-mode="REPLACE"
              data-ajax="true" data-ajax-method="GET">
  <div class="py-3">
    <div id="Results">Place holder will be replaced by time when you click the button</div>
  </div>
  <input type="submit" value="Get time" class="btn btn-primary" />
</form>

Complete mapping of each AjaxOptions with new HTML attribute can be found here: jQuery Unobtrusive Ajax Helpers in ASP.NET Core

About

Demo of how to do AJAX calls in Asp.Net Core 2

Resources

License

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors