Using Unobtrusive Ajax Links
The Ajax
HTML helper will also produce links that are followed asynchronously using Ajax. I have used this feature in Listing 30-11 to create a set of links that load the data for each of the available events.
Listing 30-11. Generating Ajax links
@model string
@{
ViewBag.Title = Model + " Report";
AjaxOptions ajaxOpts = new AjaxOptions {
UpdateTargetId = "datatable",
Url = Url.Action("RegistrationTable"),
LoadingElementId = "loading",
LoadingElementDuration = 2000,
OnBegin = "ClearTableData"
};
}
<script type="text/javascript">
function ClearTableData() {
$('#datatable td').remove();
}
</script>
<h2>@Model</h2>
@using (Ajax.BeginForm("Index", ...
Get Applied ASP.NET 4 in Context 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.