HtmlHelperValidationExtensions Class

Validation-related extensions for Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper and Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper`1.

Namespace
Microsoft.AspNetCore.Mvc.Rendering
Assemblies
  • Microsoft.AspNetCore.Mvc.ViewFeatures

Syntax

public class HtmlHelperValidationExtensions
class Microsoft.AspNetCore.Mvc.Rendering.HtmlHelperValidationExtensions

Methods

ValidationMessage(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String)

Returns the validation message if an error exists in the Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary object for the specified <em>expression</em>.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing a Microsoft.AspNetCore.Mvc.Rendering.ViewContext.ValidationMessageElement element. <code>null</code> if the <em>expression</em> is valid and client-side validation is disabled.

public static IHtmlContent ValidationMessage(this IHtmlHelper htmlHelper, string expression)
ValidationMessage(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String, System.Object)

Returns the validation message if an error exists in the Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary object for the specified <em>expression</em>.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing a Microsoft.AspNetCore.Mvc.Rendering.ViewContext.ValidationMessageElement element. <code>null</code> if the <em>expression</em> is valid and client-side validation is disabled.

public static IHtmlContent ValidationMessage(this IHtmlHelper htmlHelper, string expression, object htmlAttributes)
ValidationMessage(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String, System.String)

Returns the validation message if an error exists in the Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary object for the specified <em>expression</em>.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing a Microsoft.AspNetCore.Mvc.Rendering.ViewContext.ValidationMessageElement element. <code>null</code> if the <em>expression</em> is valid and client-side validation is disabled.

public static IHtmlContent ValidationMessage(this IHtmlHelper htmlHelper, string expression, string message)
ValidationMessage(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String, System.String, System.Object)

Returns the validation message if an error exists in the Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary object for the specified <em>expression</em>.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing a Microsoft.AspNetCore.Mvc.Rendering.ViewContext.ValidationMessageElement element. <code>null</code> if the <em>expression</em> is valid and client-side validation is disabled.

public static IHtmlContent ValidationMessage(this IHtmlHelper htmlHelper, string expression, string message, object htmlAttributes)
ValidationMessage(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String, System.String, System.String)

Returns the validation message if an error exists in the Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary object for the specified <em>expression</em>.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing a <em>tag</em> element. <code>null</code> if the <em>expression</em> is valid and client-side validation is disabled.

public static IHtmlContent ValidationMessage(this IHtmlHelper htmlHelper, string expression, string message, string tag)
ValidationMessageFor<TModel, TResult>(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel, TResult>>)

Returns the validation message if an error exists in the Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary object for the specified <em>expression</em>.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing a Microsoft.AspNetCore.Mvc.Rendering.ViewContext.ValidationMessageElement element. <code>null</code> if the <em>expression</em> is valid and client-side validation is disabled.

public static IHtmlContent ValidationMessageFor<TModel, TResult>(this IHtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TResult>> expression)
ValidationMessageFor<TModel, TResult>(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel, TResult>>, System.String)

Returns the validation message if an error exists in the Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary object for the specified <em>expression</em>.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing a Microsoft.AspNetCore.Mvc.Rendering.ViewContext.ValidationMessageElement element. <code>null</code> if the <em>expression</em> is valid and client-side validation is disabled.

public static IHtmlContent ValidationMessageFor<TModel, TResult>(this IHtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TResult>> expression, string message)
ValidationMessageFor<TModel, TResult>(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel, TResult>>, System.String, System.Object)

Returns the validation message if an error exists in the Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary object for the specified <em>expression</em>.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing a Microsoft.AspNetCore.Mvc.Rendering.ViewContext.ValidationMessageElement element. <code>null</code> if the <em>expression</em> is valid and client-side validation is disabled.

public static IHtmlContent ValidationMessageFor<TModel, TResult>(this IHtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TResult>> expression, string message, object htmlAttributes)
ValidationMessageFor<TModel, TResult>(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel, TResult>>, System.String, System.String)

Returns the validation message if an error exists in the Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary object for the specified <em>expression</em>.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing the <em>tag</em> element. <code>null</code> if the <em>expression</em> is valid and client-side validation is disabled.

public static IHtmlContent ValidationMessageFor<TModel, TResult>(this IHtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TResult>> expression, string message, string tag)
ValidationSummary(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper)

Returns an unordered list (<ul> element) of validation messages that are in the Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary object.

Arguments:htmlHelper (Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper) – The Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper instance this method extends.
Return type:Microsoft.AspNetCore.Html.IHtmlContent
Returns:New Microsoft.AspNetCore.Html.IHtmlContent containing a <div> element wrapping the <ul> element. Microsoft.AspNetCore.Html.HtmlString.Empty if the current model is valid and client-side validation is disabled).
public static IHtmlContent ValidationSummary(this IHtmlHelper htmlHelper)
ValidationSummary(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.Boolean)

Returns an unordered list (<ul> element) of validation messages that are in the Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary object.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

New Microsoft.AspNetCore.Html.IHtmlContent containing a <div> element wrapping the <ul> element. Microsoft.AspNetCore.Html.HtmlString.Empty if the current model is valid and client-side validation is disabled).

public static IHtmlContent ValidationSummary(this IHtmlHelper htmlHelper, bool excludePropertyErrors)
ValidationSummary(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.Boolean, System.String)

Returns an unordered list (<ul> element) of validation messages that are in the Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary object.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

New Microsoft.AspNetCore.Html.IHtmlContent containing a <div> element wrapping the Microsoft.AspNetCore.Mvc.Rendering.ViewContext.ValidationSummaryMessageElement element (which, in turn, wraps the <em>message</em>) and the <ul> element. Microsoft.AspNetCore.Html.HtmlString.Empty if the current model is valid and client-side validation is disabled).

public static IHtmlContent ValidationSummary(this IHtmlHelper htmlHelper, bool excludePropertyErrors, string message)
ValidationSummary(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.Boolean, System.String, System.Object)

Returns an unordered list (<ul> element) of validation messages that are in the Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary object.

Arguments:
  • htmlHelper (Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper) – The Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper instance this method extends.
  • excludePropertyErrors (System.Boolean) – If <code>true</code>, display model-level errors only; otherwise display all errors.
  • message (System.String) – The message to display with the validation summary.
  • htmlAttributes (System.Object) – An System.Object that contains the HTML attributes for the topmost (<div>) element. Alternatively, an System.Collections.Generic.IDictionary`2 instance containing the HTML attributes.
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

New Microsoft.AspNetCore.Html.IHtmlContent containing a <div> element wrapping the Microsoft.AspNetCore.Mvc.Rendering.ViewContext.ValidationSummaryMessageElement element (which wraps the <em>message</em>) and the <ul> element. Microsoft.AspNetCore.Html.HtmlString.Empty if the current model is valid and client-side validation is disabled).

public static IHtmlContent ValidationSummary(this IHtmlHelper htmlHelper, bool excludePropertyErrors, string message, object htmlAttributes)
ValidationSummary(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.Boolean, System.String, System.String)

Returns an unordered list (<ul> element) of validation messages that are in the Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary object.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

New Microsoft.AspNetCore.Html.IHtmlContent containing a <div> element wrapping the <em>tag</em> element and the <ul> element. Microsoft.AspNetCore.Html.HtmlString.Empty if the current model is valid and client-side validation is disabled).

public static IHtmlContent ValidationSummary(this IHtmlHelper htmlHelper, bool excludePropertyErrors, string message, string tag)
ValidationSummary(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String)

Returns an unordered list (<ul> element) of validation messages that are in the Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary object.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

New Microsoft.AspNetCore.Html.IHtmlContent containing a <div> element wrapping the Microsoft.AspNetCore.Mvc.Rendering.ViewContext.ValidationSummaryMessageElement element (which wraps the <em>message</em>) and the <ul> element. Microsoft.AspNetCore.Html.HtmlString.Empty if the current model is valid and client-side validation is disabled).

public static IHtmlContent ValidationSummary(this IHtmlHelper htmlHelper, string message)
ValidationSummary(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String, System.Object)

Returns an unordered list (<ul> element) of validation messages that are in the Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary object.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

New Microsoft.AspNetCore.Html.IHtmlContent containing a <div> element wrapping the Microsoft.AspNetCore.Mvc.Rendering.ViewContext.ValidationSummaryMessageElement element (which wraps the <em>message</em>) and the <ul> element. Microsoft.AspNetCore.Html.HtmlString.Empty if the current model is valid and client-side validation is disabled).

public static IHtmlContent ValidationSummary(this IHtmlHelper htmlHelper, string message, object htmlAttributes)
ValidationSummary(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String, System.Object, System.String)

Returns an unordered list (<ul> element) of validation messages that are in the Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary object.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

New Microsoft.AspNetCore.Html.IHtmlContent containing a <div> element wrapping the <em>tag</em> element and the <ul> element. Microsoft.AspNetCore.Html.HtmlString.Empty if the current model is valid and client-side validation is disabled).

public static IHtmlContent ValidationSummary(this IHtmlHelper htmlHelper, string message, object htmlAttributes, string tag)
ValidationSummary(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String, System.String)

Returns an unordered list (<ul> element) of validation messages that are in the Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary object.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

New Microsoft.AspNetCore.Html.IHtmlContent containing a <div> element wrapping the <em>tag</em> element and the <ul> element. Microsoft.AspNetCore.Html.HtmlString.Empty if the current model is valid and client-side validation is disabled).

public static IHtmlContent ValidationSummary(this IHtmlHelper htmlHelper, string message, string tag)