ValidationExtensions.ValidationMessageFor Method

 

Returns the HTML markup for a validation-error message for each data field that is represented by the specified expression.

Namespace:   System.Web.Mvc.Html
Assembly:  System.Web.Mvc (in System.Web.Mvc.dll)

NameDescription
System_CAPS_pubmethodSystem_CAPS_staticValidationMessageFor(Of TModel, TProperty)(HtmlHelper(Of TModel), Expression(Of Func(Of TModel, TProperty)))

Returns the HTML markup for a validation-error message for each data field that is represented by the specified expression.

System_CAPS_pubmethodSystem_CAPS_staticValidationMessageFor(Of TModel, TProperty)(HtmlHelper(Of TModel), Expression(Of Func(Of TModel, TProperty)), String)

Returns the HTML markup for a validation-error message for each data field that is represented by the specified expression, using the specified message.

System_CAPS_pubmethodSystem_CAPS_staticValidationMessageFor(Of TModel, TProperty)(HtmlHelper(Of TModel), Expression(Of Func(Of TModel, TProperty)), String, IDictionary(Of String, Object))

Returns the HTML markup for a validation-error message for each data field that is represented by the specified expression, using the specified message and HTML attributes.

System_CAPS_pubmethodSystem_CAPS_staticValidationMessageFor(Of TModel, TProperty)(HtmlHelper(Of TModel), Expression(Of Func(Of TModel, TProperty)), String, IDictionary(Of String, Object), String)

Returns the HTML markup for a validation-error message for the specified expression.

System_CAPS_pubmethodSystem_CAPS_staticValidationMessageFor(Of TModel, TProperty)(HtmlHelper(Of TModel), Expression(Of Func(Of TModel, TProperty)), String, Object)

Returns the HTML markup for a validation-error message for each data field that is represented by the specified expression, using the specified message and HTML attributes.

System_CAPS_pubmethodSystem_CAPS_staticValidationMessageFor(Of TModel, TProperty)(HtmlHelper(Of TModel), Expression(Of Func(Of TModel, TProperty)), String, Object, String)

Returns the HTML markup for a validation-error message for the specified expression.

System_CAPS_pubmethodSystem_CAPS_staticValidationMessageFor(Of TModel, TProperty)(HtmlHelper(Of TModel), Expression(Of Func(Of TModel, TProperty)), String, String)

Returns the HTML markup for a validation-error message for the specified expression.

Return to top

ValidationExtensions.ValidationMessageFor(Of TModel, TProperty) Method (HtmlHelper(Of TModel), Expression(Of Func(Of TModel, TProperty)))

Returns the HTML markup for a validation-error message for each data field that is represented by the specified expression.

<ExtensionAttribute>
Public Shared Function ValidationMessageFor(Of TModel, TProperty) (
	htmlHelper As HtmlHelper(Of TModel),
	expression As Expression(Of Func(Of TModel, TProperty))
) As MvcHtmlString

Parameters

htmlHelper
Type: System.Web.Mvc.HtmlHelper(Of TModel)

The HTML helper instance that this method extends.

expression
Type: System.Linq.Expressions.Expression(Of Func(Of TModelTProperty))

An expression that identifies the object that contains the properties to render.

Return Value

Type: System.Web.Mvc.MvcHtmlString

If the property or object is valid, an empty string; otherwise, a span element that contains an error message.

Type Parameters

TModel

The type of the model.

TProperty

The type of the property.

Return to top

ValidationExtensions.ValidationMessageFor(Of TModel, TProperty) Method (HtmlHelper(Of TModel), Expression(Of Func(Of TModel, TProperty)), String)

Returns the HTML markup for a validation-error message for each data field that is represented by the specified expression, using the specified message.

<ExtensionAttribute>
Public Shared Function ValidationMessageFor(Of TModel, TProperty) (
	htmlHelper As HtmlHelper(Of TModel),
	expression As Expression(Of Func(Of TModel, TProperty)),
	validationMessage As String
) As MvcHtmlString

Parameters

htmlHelper
Type: System.Web.Mvc.HtmlHelper(Of TModel)

The HTML helper instance that this method extends.

expression
Type: System.Linq.Expressions.Expression(Of Func(Of TModelTProperty))

An expression that identifies the object that contains the properties to render.

validationMessage
Type: System.String

The message to display if the specified field contains an error.

Return Value

Type: System.Web.Mvc.MvcHtmlString

If the property or object is valid, an empty string; otherwise, a span element that contains an error message.

Type Parameters

TModel

The type of the model.

TProperty

The type of the property.

Return to top

ValidationExtensions.ValidationMessageFor(Of TModel, TProperty) Method (HtmlHelper(Of TModel), Expression(Of Func(Of TModel, TProperty)), String, IDictionary(Of String, Object))

Returns the HTML markup for a validation-error message for each data field that is represented by the specified expression, using the specified message and HTML attributes.

<ExtensionAttribute>
Public Shared Function ValidationMessageFor(Of TModel, TProperty) (
	htmlHelper As HtmlHelper(Of TModel),
	expression As Expression(Of Func(Of TModel, TProperty)),
	validationMessage As String,
	htmlAttributes As IDictionary(Of StringObject)
) As MvcHtmlString

Parameters

htmlHelper
Type: System.Web.Mvc.HtmlHelper(Of TModel)

The HTML helper instance that this method extends.

expression
Type: System.Linq.Expressions.Expression(Of Func(Of TModelTProperty))

An expression that identifies the object that contains the properties to render.

validationMessage
Type: System.String

The message to display if the specified field contains an error.

htmlAttributes
Type: System.Collections.Generic.IDictionary(Of StringObject)

An object that contains the HTML attributes for the element.

Return Value

Type: System.Web.Mvc.MvcHtmlString

If the property or object is valid, an empty string; otherwise, a span element that contains an error message.

Type Parameters

TModel

The type of the model.

TProperty

The type of the property.

Return to top

ValidationExtensions.ValidationMessageFor(Of TModel, TProperty) Method (HtmlHelper(Of TModel), Expression(Of Func(Of TModel, TProperty)), String, IDictionary(Of String, Object), String)

Returns the HTML markup for a validation-error message for the specified expression.

<ExtensionAttribute>
Public Shared Function ValidationMessageFor(Of TModel, TProperty) (
	htmlHelper As HtmlHelper(Of TModel),
	expression As Expression(Of Func(Of TModel, TProperty)),
	validationMessage As String,
	htmlAttributes As IDictionary(Of StringObject),
	tag As String
) As MvcHtmlString

Parameters

htmlHelper
Type: System.Web.Mvc.HtmlHelper(Of TModel)

The HTML helper instance that this method operates on.

expression
Type: System.Linq.Expressions.Expression(Of Func(Of TModelTProperty))

An expression that identifies the object that contains the properties to render.

validationMessage
Type: System.String

The message to display if a validation error occurs.

htmlAttributes
Type: System.Collections.Generic.IDictionary(Of StringObject)

An IDictionary(Of TKey, TValue) that contains the HTML attributes for the element.

tag
Type: System.String

The tag to be set for the wrapping HTML element of the validation message.

Return Value

Type: System.Web.Mvc.MvcHtmlString

null if the model object is valid and client-side validation is disabled. Otherwise, a tag element that contains an error message.

Type Parameters

TModel

The type of the model.

TProperty

The type of the property.

Return to top

ValidationExtensions.ValidationMessageFor(Of TModel, TProperty) Method (HtmlHelper(Of TModel), Expression(Of Func(Of TModel, TProperty)), String, Object)

Returns the HTML markup for a validation-error message for each data field that is represented by the specified expression, using the specified message and HTML attributes.

<ExtensionAttribute>
Public Shared Function ValidationMessageFor(Of TModel, TProperty) (
	htmlHelper As HtmlHelper(Of TModel),
	expression As Expression(Of Func(Of TModel, TProperty)),
	validationMessage As String,
	htmlAttributes As Object
) As MvcHtmlString

Parameters

htmlHelper
Type: System.Web.Mvc.HtmlHelper(Of TModel)

The HTML helper instance that this method extends.

expression
Type: System.Linq.Expressions.Expression(Of Func(Of TModelTProperty))

An expression that identifies the object that contains the properties to render.

validationMessage
Type: System.String

The message to display if the specified field contains an error.

htmlAttributes
Type: System.Object

An object that contains the HTML attributes for the element.

Return Value

Type: System.Web.Mvc.MvcHtmlString

If the property or object is valid, an empty string; otherwise, a span element that contains an error message.

Type Parameters

TModel

The type of the model.

TProperty

The type of the property.

Client validation must be enabled.

Return to top

ValidationExtensions.ValidationMessageFor(Of TModel, TProperty) Method (HtmlHelper(Of TModel), Expression(Of Func(Of TModel, TProperty)), String, Object, String)

Returns the HTML markup for a validation-error message for the specified expression.

<ExtensionAttribute>
Public Shared Function ValidationMessageFor(Of TModel, TProperty) (
	htmlHelper As HtmlHelper(Of TModel),
	expression As Expression(Of Func(Of TModel, TProperty)),
	validationMessage As String,
	htmlAttributes As Object,
	tag As String
) As MvcHtmlString

Parameters

htmlHelper
Type: System.Web.Mvc.HtmlHelper(Of TModel)

The HTML helper instance that this method operates on.

expression
Type: System.Linq.Expressions.Expression(Of Func(Of TModelTProperty))

An expression that identifies the object that contains the properties to render.

validationMessage
Type: System.String

The message to display if a validation error occurs.

htmlAttributes
Type: System.Object

An object that contains the HTML attributes for the element.

tag
Type: System.String

The tag to be set for the wrapping HTML element of the validation message.

Return Value

Type: System.Web.Mvc.MvcHtmlString

null if the model object is valid and client-side validation is disabled. Otherwise, a tag element that contains an error message.

Type Parameters

TModel

The type of the model.

TProperty

The type of the property.

Return to top

ValidationExtensions.ValidationMessageFor(Of TModel, TProperty) Method (HtmlHelper(Of TModel), Expression(Of Func(Of TModel, TProperty)), String, String)

Returns the HTML markup for a validation-error message for the specified expression.

<ExtensionAttribute>
Public Shared Function ValidationMessageFor(Of TModel, TProperty) (
	htmlHelper As HtmlHelper(Of TModel),
	expression As Expression(Of Func(Of TModel, TProperty)),
	validationMessage As String,
	tag As String
) As MvcHtmlString

Parameters

htmlHelper
Type: System.Web.Mvc.HtmlHelper(Of TModel)

The HTML helper instance that this method operates on.

expression
Type: System.Linq.Expressions.Expression(Of Func(Of TModelTProperty))

An expression that identifies the object that contains the properties to render.

validationMessage
Type: System.String

The message to display if a validation error occurs.

tag
Type: System.String

The tag to be set for the wrapping HTML element of the validation message.

Return Value

Type: System.Web.Mvc.MvcHtmlString

null if the model object is valid and client-side validation is disabled. Otherwise, a tag element that contains an error message.

Type Parameters

TModel

The type of the model.

TProperty

The type of the property.

Return to top
Show: