IHtmlHelper.ValidationMessage(String, String, Object, String) IHtmlHelper.ValidationMessage(String, String, Object, String) IHtmlHelper.ValidationMessage(String, String, Object, String) Method

Definition

Returns the validation message if an error exists in the ModelStateDictionary object for the specified expression.

public Microsoft.AspNetCore.Html.IHtmlContent ValidationMessage (string expression, string message, object htmlAttributes, string tag);
abstract member ValidationMessage : string * string * obj * string -> Microsoft.AspNetCore.Html.IHtmlContent
Public Function ValidationMessage (expression As String, message As String, htmlAttributes As Object, tag As String) As IHtmlContent

Parameters

expression
String String String

Expression name, relative to the current model.

message
String String 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.

htmlAttributes
Object Object Object

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

tag
String String String

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

Returns

A new IHtmlContent containing a tag element. An empty IHtmlContent if the expression is valid and client-side validation is disabled.

Applies to