O'Reilly logo

Applied ASP.NET 4 in Context by Adam Freeman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using Unobtrusive Ajax Forms

Let's use the MVC support for Ajax to add support for posting forms for updates. Listing 30-6 shows the changes to the Index.cshtml view to enable this feature.

Listing 30-6. Using Ajax forms

@model string @{     ViewBag.Title = Model + " Report";     AjaxOptions ajaxOpts = new AjaxOptions {         UpdateTargetId = "datatable"     }; } <h2>@Model</h2> @using (Ajax.BeginForm("RegistrationTable", ajaxOpts)) {     @Html.DropDownList("competition", new SelectList(ViewBag.CompetitionNames, Model))     <input type="submit" value="Show Report" /> } <p /> @Html.Action("RegistrationTable", new { competition = Model })

We have to make two changes to enable Ajax forms. The first is to define an AjaxOptions object, which ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required