ValidationHtmlAttributeProvider.AddAndTrackValidationAttributes Method

Definition

Adds validation-related HTML attributes to the attributes if client validation is enabled and validation attributes have not yet been added for this expression in the current <form>.

public:
 virtual void AddAndTrackValidationAttributes(Microsoft::AspNetCore::Mvc::Rendering::ViewContext ^ viewContext, Microsoft::AspNetCore::Mvc::ViewFeatures::ModelExplorer ^ modelExplorer, System::String ^ expression, System::Collections::Generic::IDictionary<System::String ^, System::String ^> ^ attributes);
public virtual void AddAndTrackValidationAttributes (Microsoft.AspNetCore.Mvc.Rendering.ViewContext viewContext, Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExplorer modelExplorer, string expression, System.Collections.Generic.IDictionary<string,string> attributes);
abstract member AddAndTrackValidationAttributes : Microsoft.AspNetCore.Mvc.Rendering.ViewContext * Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExplorer * string * System.Collections.Generic.IDictionary<string, string> -> unit
override this.AddAndTrackValidationAttributes : Microsoft.AspNetCore.Mvc.Rendering.ViewContext * Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExplorer * string * System.Collections.Generic.IDictionary<string, string> -> unit
Public Overridable Sub AddAndTrackValidationAttributes (viewContext As ViewContext, modelExplorer As ModelExplorer, expression As String, attributes As IDictionary(Of String, String))

Parameters

viewContext
ViewContext

A ViewContext instance for the current scope.

modelExplorer
ModelExplorer

The ModelExplorer for the expression.

expression
String

Expression name, relative to the current model.

attributes
IDictionary<String,String>

The Dictionary<TKey,TValue> to receive the validation attributes. Maps the validation attribute names to their String values. Values must be HTML encoded before they are written to an HTML document or response.

Remarks

Tracks the expression in the current FormContext to avoid generating duplicate validation attributes. That is, validation attributes are added only if no previous call has added them for a field with this name in the <form>.

Applies to