RemoteAttribute Class

Summary

A [System.ComponentModel.DataAnnotations.ValidationAttribute]() which configures Unobtrusive validation to send an Ajax request to the web site. The invoked action should return JSON indicating whether the value is valid.

Inheritance Hierarchy

Syntax

public class RemoteAttribute : ValidationAttribute, _Attribute, IClientModelValidator

GitHub

View on GitHub

class Microsoft.AspNet.Mvc.RemoteAttribute

Constructors

Microsoft.AspNet.Mvc.RemoteAttribute.RemoteAttribute()

Initializes a new instance of the [Microsoft.AspNet.Mvc.RemoteAttribute](Microsoft.AspNet.Mvc.RemoteAttribute.yml) class.

protected RemoteAttribute()
RemoteAttribute(System.String)

Initializes a new instance of the [Microsoft.AspNet.Mvc.RemoteAttribute](Microsoft.AspNet.Mvc.RemoteAttribute.yml) class.

Arguments:
  • routeName (System.String) – The route name used when generating the URL where client should send a validation request.
public RemoteAttribute(string routeName)
RemoteAttribute(System.String, System.String)

Initializes a new instance of the [Microsoft.AspNet.Mvc.RemoteAttribute](Microsoft.AspNet.Mvc.RemoteAttribute.yml) class.

Arguments:
  • action (System.String) – The action name used when generating the URL where client should send a validation request.
  • controller (System.String) – The controller name used when generating the URL where client should send a validation request.
public RemoteAttribute(string action, string controller)
RemoteAttribute(System.String, System.String, System.String)

Initializes a new instance of the [Microsoft.AspNet.Mvc.RemoteAttribute](Microsoft.AspNet.Mvc.RemoteAttribute.yml) class.

Arguments:
  • action (System.String) – The action name used when generating the URL where client should send a validation request.
  • controller (System.String) – The controller name used when generating the URL where client should send a validation request.
  • areaName (System.String) – The name of the area containing the <paramref name=”controller” />.
public RemoteAttribute(string action, string controller, string areaName)

Properties

AdditionalFields()

Gets or sets the comma-separated names of fields the client should include in a validation request.

Return type:System.String
public string AdditionalFields { get; set; }
HttpMethod()

Gets or sets the HTTP method ( <c>”Get”</c> or <c>”Post”</c>) client should use when sending a validation request.

Return type:System.String
public string HttpMethod { get; set; }
RouteData()

Gets the @!:RouteValueDictionary- used when generating the URL where client should send a validation request.

Return type:RouteValueDictionary
protected RouteValueDictionary RouteData { get; }
RouteName()

Gets or sets the route name used when generating the URL where client should send a validation request.

Return type:System.String
protected string RouteName { get; set; }

Methods

FormatAdditionalFieldsForClientValidation(System.String)

Formats <paramref name=”property” /> and [Microsoft.AspNet.Mvc.RemoteAttribute.AdditionalFields](Microsoft.AspNet.Mvc.RemoteAttribute.yml) for use in generated HTML.

Arguments:
  • property (System.String) – Name of the property associated with this [Microsoft.AspNet.Mvc.RemoteAttribute](Microsoft.AspNet.Mvc.RemoteAttribute.yml) instance.
Return type:

System.String

Returns:

Comma-separated names of fields the client should include in a validation request.

public string FormatAdditionalFieldsForClientValidation(string property)
FormatErrorMessage(System.String)
Arguments:
  • name (System.String) –
Return type:

System.String

public override string FormatErrorMessage(string name)
FormatPropertyForClientValidation(System.String)

Formats <paramref name=”property” /> for use in generated HTML.

Arguments:
  • property (System.String) – One field name the client should include in a validation request.
Return type:

System.String

Returns:

Name of a field the client should include in a validation request.

public static string FormatPropertyForClientValidation(string property)
GetClientValidationRules(Microsoft.AspNet.Mvc.ModelBinding.Validation.ClientModelValidationContext)
Arguments:
Return type:

System.Collections.Generic.IEnumerable{Microsoft.AspNet.Mvc.ModelBinding.Validation.ModelClientValidationRule}

public virtual IEnumerable<ModelClientValidationRule> GetClientValidationRules(ClientModelValidationContext context)
GetUrl(Microsoft.AspNet.Mvc.ModelBinding.Validation.ClientModelValidationContext)

Returns the URL where the client should send a validation request.

Arguments:
Return type:

System.String

Returns:

The URL where the client should send a validation request.

protected virtual string GetUrl(ClientModelValidationContext context)
IsValid(System.Object)
Arguments:
  • value (System.Object) –
Return type:

System.Boolean

public override bool IsValid(object value)