Part 92 Ajax with asp net mvc



Part 92 Ajax with asp net mvc

Part 92   Ajax with asp net mvc

Link for code samples used in the demo
http://csharp-video-tutorials.blogspot.com/2013/09/part-92-ajax-with-aspnet-mvc.html

Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
https://www.youtube.com/channel/UC7sEwIXM_YfAMyonQCrGfWA/?sub_confirmation=1

Link for csharp, asp.net, ado.net, dotnet basics, mvc and sql server video tutorial playlists
http://www.youtube.com/user/kudvenkat/playlists

ASP.NET AJAX enables a Web application to retrieve data from the server asynchronously and to update portions of the existing page. So these, partial page updates make web application more responsive and hence improves user experience.

In this video, let’s discus using Ajax.ActionLink helper. By the end of this video, we should be able to load either
1. All students or
2. Top 3 students or
3. Bottom 3 students
depending on the link we have clicked.

Here are the steps to achieve this
Step 1: Create and populate table tblStudents

Step 2: Create an ado.net entity datamodel using table tblStudents. Upon creating the entity model, change the name of the entity to Student. Save changes and build the solution, so that the Student entity class gets compiled.

Step 3: Add “Shared” folder (if it doesn’t already exists) in “Views” folder. Right click on “Shared” folder and add a partial view, with name = _Student.cshtml.

Step 4: Right click on the “Controllers” folder and add a controller with the following settings
1. Controller Name = HomeController
2. Template = Empty MVC controller

Step 5: Right click on the “Views” folder and add a folder with name = “Home”. Right click on the “Home” folder and add a view with Name = “Index”.
Points to remember:
a) For AJAX to work, jquery and jquery.unobtrusive-ajax javascript files need to be referenced. Reference to jquery.unobtrusive-ajax.js file should be after jquery.js reference.
b) Ajax.ActionLink() html helper has several overloaded versions. We have used the following version
ActionLink(string linkText, string actionName, AjaxOptions ajaxOptions);

First parameter : is the link text that we see on the user interface
Second parameter : is the name of the action method that needs to be invoked, when the link is cicked.
Third parameter : is the ajaxOptions object.

Comments are closed.