IHtmlGenerator.GenerateValidationMessage Method

Definition

Generate a tag element if the viewContext's ModelState contains an error for the expression.

public:
 Microsoft::AspNetCore::Mvc::Rendering::TagBuilder ^ GenerateValidationMessage(Microsoft::AspNetCore::Mvc::Rendering::ViewContext ^ viewContext, Microsoft::AspNetCore::Mvc::ViewFeatures::ModelExplorer ^ modelExplorer, System::String ^ expression, System::String ^ message, System::String ^ tag, System::Object ^ htmlAttributes);
public Microsoft.AspNetCore.Mvc.Rendering.TagBuilder GenerateValidationMessage (Microsoft.AspNetCore.Mvc.Rendering.ViewContext viewContext, Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExplorer modelExplorer, string expression, string message, string tag, object htmlAttributes);
abstract member GenerateValidationMessage : Microsoft.AspNetCore.Mvc.Rendering.ViewContext * Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExplorer * string * string * string * obj -> Microsoft.AspNetCore.Mvc.Rendering.TagBuilder
Public Function GenerateValidationMessage (viewContext As ViewContext, modelExplorer As ModelExplorer, expression As String, message As String, tag As String, htmlAttributes As Object) As TagBuilder

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.

message
String

The message to be displayed. If null or empty, method extracts an error string from the ModelStateDictionary object. Message will always be visible but client-side validation may update the associated CSS class.

tag
String

The tag to wrap the message in the generated HTML. Its default value is ValidationMessageElement.

htmlAttributes
Object

An Object that contains the HTML attributes for the element. Alternatively, an IDictionary<TKey,TValue> instance containing the HTML attributes.

Returns

Remarks

ValidationMessageElement is "span" by default.

Applies to