Hi @Game Warden ,
If I do this regular way (public IActionResult NameOfEndp()) in order to fetch the new records I have to refresh the page. How, can I fetch the new data without refreshing the page?
You can use partial view to list the records and use JQuery Ajax to refresh it, and you can also use JQuery Ajax to perform CRUD operations in asp.net core MVC.
Refer to the following sample:
Create a Customer model and CustomerView model:
public class Customer //database entity
{
public int CustomerId { get; set; }
public string CustomerName { get; set; }
public string Description { get; set; }
}
public class CustomerViewModel //used to transfer data between view and controller
{
public string Name { get; set; }
public string Descriptsion { get; set; }
}
Then, enable migration and add the Customer table in the database, using the ApplicationDbContext.
Controller:
Code in the Index.cshtml:
The partial view looks like:
You can view the Controller code, Index.cshtml and the Partail view code from here: 261197-sourcecode.txt
The result like this:
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Dillion