Data binding in ASP .NET using AJAX & SQL Database

This post is illustrate the process of data sharing from server to client using AJAX.

There are lots of advantages of using AJAX. The Main advantage of using AJAX is we just need to transfer data which is required. For example when HTML page loaded then for each subsequent operation (Excluding the redirect) we don't need to reload page again and again.

Let's see how this can be implemented in ASP .NET Webform as well as ASP .NET MVC.

Created simple product table, we will be retrieving data from this table only.


I am using ADO.NET for database connection.

We will use JQuery library to make an ajax call to the server.


WebForm

In case of WebForm, we will create WebMethod which will be called using AJAX.


On Client side above webmethod is called using JQuery AJAX.

The result is


MVC
In case on MVC, we will create Method in controller which will return JsonResult.

On Client side in Razor it will be called using JQuery AJAX.

The result is


For any queries comment below.

Comments