AJAX Helpers
You've seen the HTML helpers in ASP.NET MVC. You can use the HTML helpers to create forms and links that point to controller actions. There is also a set of AJAX helpers in ASP.NET MVC. AJAX helpers also create forms and links that point to controller actions, but they behave asynchronously. When using these helpers, you don't need to write any script code to make the asynchrony work.
Behind the scenes, these AJAX helpers depend on the unobtrusive MVC extensions for jQuery. To use the helpers, you need to have the jquery.unobtrusive-ajax script present. Because you might be using this functionality in a number of places in the application, you can include this file in the layout view (after including jQuery).
<script src="@Url.Content("∼/Scripts/jquery-1.4.4.min.js")" type="text/javascript"></script> <script src="@Url.Content("∼/Scripts/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script> @RenderSection("scripts", required:false);
AJAX ActionLinks
AJAX helpers are available through the Ajax property inside a Razor view. Like HTML helpers, most of the methods on this property are extension methods (but for the AjaxHelper type).
The ActionLink method of the Ajax property creates an anchor tag with asynchronous behavior. Imagine you want to add a “daily deal” link at the bottom of the opening page for the MVC Music Store. When users click the link, you don't want them to navigate to a new page, but you want the existing page to magically display ...
Get Professional ASP.NET MVC 3 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.