Remote Validator
ASP.NET MVC 3 supports the new RemoteAttribute class that enables you to take advantage of the jQuery Validation plug-in's remote validator support. This enables the client-side validation library to automatically call a custom method that you define on the server in order to perform validation logic that can only be done server-side.
In the following example, the
Remote
attribute specifies that client validation will call an action namedUserNameAvailable
on the UsersController
class in order to validate the UserName
field.public class User { [Remote("UserNameAvailable", "Users")] public string UserName { get; set; } }
The following example shows the corresponding controller.
public class UsersController { public bool UserNameAvailable(string username) { if(MyRepository.UserNameExists(username)) { return "false"; } return "true"; } }
For more information about how to use the
Remote
attribute.The above content is Taken from www.asp.net help file read full from here
0 comments:
Post a Comment