RemoteAttribute Class¶
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.
- Namespace
Microsoft.AspNetCore.Mvc- Assemblies
- Microsoft.AspNetCore.Mvc.ViewFeatures
Inheritance Hierarchy¶
System.ObjectSystem.AttributeSystem.ComponentModel.DataAnnotations.ValidationAttributeMicrosoft.AspNetCore.Mvc.RemoteAttribute
Syntax¶
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public class RemoteAttribute : ValidationAttribute, _Attribute, IClientModelValidator
-
class
Microsoft.AspNetCore.Mvc.RemoteAttribute
Constructors¶
-
RemoteAttribute()¶ Initializes a new instance of the
Microsoft.AspNetCore.Mvc.RemoteAttributeclass.protected RemoteAttribute()
-
RemoteAttribute(System.String) Initializes a new instance of the
Microsoft.AspNetCore.Mvc.RemoteAttributeclass.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.AspNetCore.Mvc.RemoteAttributeclass.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.AspNetCore.Mvc.RemoteAttributeclass.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 <em>controller</em>.
public RemoteAttribute(string action, string controller, string areaName)
-
Properties¶
-
Microsoft.AspNetCore.Mvc.RemoteAttribute.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; }
-
Microsoft.AspNetCore.Mvc.RemoteAttribute.HttpMethod¶ Gets or sets the HTTP method (<code>”Get”</code> or <code>”Post”</code>) client should use when sending a validation request.
Return type: System.String public string HttpMethod { get; set; }
-
Microsoft.AspNetCore.Mvc.RemoteAttribute.RouteData¶ Gets the
Microsoft.AspNetCore.Routing.RouteValueDictionaryused when generating the URL where client should send a validation request.Return type: Microsoft.AspNetCore.Routing.RouteValueDictionary protected RouteValueDictionary RouteData { get; }
-
Microsoft.AspNetCore.Mvc.RemoteAttribute.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¶
-
AddValidation(Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ClientModelValidationContext)¶ public virtual void AddValidation(ClientModelValidationContext context)
-
FormatAdditionalFieldsForClientValidation(System.String)¶ Formats <em>property</em> and
Microsoft.AspNetCore.Mvc.RemoteAttribute.AdditionalFieldsfor use in generated HTML.Arguments: property (System.String) – Name of the property associated with this Microsoft.AspNetCore.Mvc.RemoteAttributeinstance.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)¶ Return type: System.String public override string FormatErrorMessage(string name)
-
FormatPropertyForClientValidation(System.String)¶ Formats <em>property</em> 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)
-
GetUrl(Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ClientModelValidationContext)¶ Returns the URL where the client should send a validation request.
Arguments: context (Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ClientModelValidationContext) – The Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ClientModelValidationContextused to generate the URL.Return type: System.String Returns: The URL where the client should send a validation request. protected virtual string GetUrl(ClientModelValidationContext context)
-
IsValid(System.Object)¶ Return type: System.Boolean public override bool IsValid(object value)
-