Performing Remote Validation
The last Ajax feature we will look at in this chapter is remote validation. This is a hybrid of the model validation techniques I showed you in Chapter 29. The validity of a property is evaluated by an action method invoked using an Ajax call at the client. The first step in setting up remote validation is to add an action method to the controller to perform the evaluation. Listing 30-15 shows such a method, which I have added to the RegistrationController
class since this is the controller that contains the validation logic from Chapter 29.
Listing 30-15. Adding a remote validation action method to a controller
using System;
using System.Linq;
using System.Web.Mvc;
using EventRegistration.Models.Domain; using EventRegistration.Models.Domain.Repository; ...
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.