jQuery Ajax CRUD in ASP.NET Core MVC with Modal Popup

jQuery Ajax CRUD in ASP.NET Core MVC with Modal Popup

In this article, we’ll discuss how to use jQuery Ajax for ASP.NET Core MVC CRUD Operations using Bootstrap Modal. With jQuery Ajax, we can make HTTP request to controller action methods without reloading the entire page, like a single page application.

In this article, we’ll discuss how to use jQuery Ajax for ASP.NET Core MVC CRUD Operations using Bootstrap Modal. With jQuery Ajax, we can make HTTP request to controller action methods without reloading the entire page, like a single page application.

To demonstrate CRUD operations – insert, update, delete and retrieve, the project will be dealing with details of a normal bank transaction. GitHub repository for this demo project : https://bit.ly/33KTJAu.

Sub-topics discussed :

  • Form design for insert and update operation.
  • Display forms in modal popup dialog.
  • Form post using jQuery Ajax.
  • Implement MVC CRUD operations with jQuery Ajax.
  • Loading spinner in .NET Core MVC.
  • Prevent direct access to MVC action method.

Create ASP.NET Core MVC Project

In Visual Studio 2019, Go to File > New > Project (Ctrl + Shift + N).

From new project window, Select Asp.Net Core Web Application_._

Image showing how to create ASP.NET Core Web API project in Visual Studio.

Once you provide the project name and location. Select Web Application(Model-View-Controller) and uncheck HTTPS Configuration. Above steps will create a brand new ASP.NET Core MVC project.

Showing project template selection for .NET Core MVC.

Setup a Database

Let’s create a database for this application using Entity Framework Core. For that we’ve to install corresponding NuGet Packages. Right click on project from solution explorer, select Manage NuGet Packages_,_ From browse tab, install following 3 packages.

Showing list of NuGet Packages for Entity Framework Core

Now let’s define DB model class file – /Models/TransactionModel.cs.

public class TransactionModel
{
    [Key]
    public int TransactionId { get; set; }

    [Column(TypeName ="nvarchar(12)")]
    [DisplayName("Account Number")]
    [Required(ErrorMessage ="This Field is required.")]
    [MaxLength(12,ErrorMessage ="Maximum 12 characters only")]
    public string AccountNumber { get; set; }

    [Column(TypeName ="nvarchar(100)")]
    [DisplayName("Beneficiary Name")]
    [Required(ErrorMessage = "This Field is required.")]
    public string BeneficiaryName { get; set; }

    [Column(TypeName ="nvarchar(100)")]
    [DisplayName("Bank Name")]
    [Required(ErrorMessage = "This Field is required.")]
    public string BankName { get; set; }

    [Column(TypeName ="nvarchar(11)")]
    [DisplayName("SWIFT Code")]
    [Required(ErrorMessage = "This Field is required.")]
    [MaxLength(11)]
    public string SWIFTCode { get; set; }

    [DisplayName("Amount")]
    [Required(ErrorMessage = "This Field is required.")]
    public int Amount { get; set; }

    [DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}")]
    public DateTime Date { get; set; }
}

C#Copy

Here we’ve defined model properties for the transaction with proper validation. Now let’s define  DbContextclass for EF Core.

asp.net core article asp.net core add loading spinner in asp.net core asp.net core crud without reloading asp.net core jquery ajax form asp.net core modal dialog asp.net core mvc crud using jquery ajax asp.net core mvc with jquery and ajax asp.net core popup window bootstrap modal popup in asp.net core mvc. bootstrap modal popup in asp.net core delete and viewall in asp.net core jquery ajax - insert jquery ajax form post modal popup dialog in asp.net core no direct access action method update validation in modal popup

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

MVC User Registration & Login with ASP.NET Core Identity

In this article, we will discuss the quickest way to use ASP.NET Core Identity for User Login and Registration in a new or existing MVC application.

Asp.Net Core MVC CRUD with EF Core

Demonstrate how you can implement Asp.Net Core MVC CRUD operations.In template wizard, Select Web Application( MVC ) template. Make sure to select latest Asp.Net Core Version from top dropdown. We don’t need to configure this application with HTTPS (Unchecked corresponding option from bottom). For this application development, we will use EF Core – Code First Approach. First of all, we have to install NuGet Package for EFCore

Jquery from validation || ASP NET Core client side validation

LIKE | COMMENT | SHARE | SUBSCRIBE In this video, I will show you how to add form validation using jquery. Subscribe & Stay Connected! Thank You! ♥ #Identity...

jQuery Ajax CRUD in ASP.NET Core MVC using Popup Dialog

In this tutorial, we've implemented jQuery Ajax CRUD in ASP.NET Core MVC using Modal Popup dialog. Now a day these types of user interface/ methods are used in enterprise applications so that we can avoid reloading of the page to do operations in a single controller.

ASP.NET Core MVC Login and Registration with Identity

In this article, we discuss how to implement ASP.NET Core MVC user authentication and registration with Identity.UI. Sub-topics discussed : * How to add ASP.NET Core Identity to an existing project. * Customize ASP.NET Core Identity . *...