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<TModel, TProperty>(HtmlHelper<TModel>, Expression<Func<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<TModel, TProperty>(HtmlHelper<TModel>, Expression<Func<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<TModel, TProperty>(HtmlHelper<TModel>, Expression<Func<TModel, TProperty>>, String, IDictionary<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<TModel, TProperty>(HtmlHelper<TModel>, Expression<Func<TModel, TProperty>>, String, IDictionary<String, Object>, String)

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

System_CAPS_pubmethodSystem_CAPS_staticValidationMessageFor<TModel, TProperty>(HtmlHelper<TModel>, Expression<Func<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<TModel, TProperty>(HtmlHelper<TModel>, Expression<Func<TModel, TProperty>>, String, Object, String)

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

System_CAPS_pubmethodSystem_CAPS_staticValidationMessageFor<TModel, TProperty>(HtmlHelper<TModel>, Expression<Func<TModel, TProperty>>, String, String)

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

Return to top

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

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

public static MvcHtmlString ValidationMessageFor<TModel, TProperty>(
	this HtmlHelper<TModel> htmlHelper,
	Expression<Func<TModel, TProperty>> expression
)

Parameters

htmlHelper
Type: System.Web.Mvc.HtmlHelper<TModel>

The HTML helper instance that this method extends.

expression
Type: System.Linq.Expressions.Expression<Func<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<TModel, TProperty> Method (HtmlHelper<TModel>, Expression<Func<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.

public static MvcHtmlString ValidationMessageFor<TModel, TProperty>(
	this HtmlHelper<TModel> htmlHelper,
	Expression<Func<TModel, TProperty>> expression,
	string validationMessage
)

Parameters

htmlHelper
Type: System.Web.Mvc.HtmlHelper<TModel>

The HTML helper instance that this method extends.

expression
Type: System.Linq.Expressions.Expression<Func<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<TModel, TProperty> Method (HtmlHelper<TModel>, Expression<Func<TModel, TProperty>>, String, IDictionary<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.

public static MvcHtmlString ValidationMessageFor<TModel, TProperty>(
	this HtmlHelper<TModel> htmlHelper,
	Expression<Func<TModel, TProperty>> expression,
	string validationMessage,
	IDictionary<stringobject> htmlAttributes
)

Parameters

htmlHelper
Type: System.Web.Mvc.HtmlHelper<TModel>

The HTML helper instance that this method extends.

expression
Type: System.Linq.Expressions.Expression<Func<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<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<TModel, TProperty> Method (HtmlHelper<TModel>, Expression<Func<TModel, TProperty>>, String, IDictionary<String, Object>, String)

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

public static MvcHtmlString ValidationMessageFor<TModel, TProperty>(
	this HtmlHelper<TModel> htmlHelper,
	Expression<Func<TModel, TProperty>> expression,
	string validationMessage,
	IDictionary<stringobject> htmlAttributes,
	string tag
)

Parameters

htmlHelper
Type: System.Web.Mvc.HtmlHelper<TModel>

The HTML helper instance that this method operates on.

expression
Type: System.Linq.Expressions.Expression<Func<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<StringObject>

An IDictionary<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<TModel, TProperty> Method (HtmlHelper<TModel>, Expression<Func<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.

public static MvcHtmlString ValidationMessageFor<TModel, TProperty>(
	this HtmlHelper<TModel> htmlHelper,
	Expression<Func<TModel, TProperty>> expression,
	string validationMessage,
	object htmlAttributes
)

Parameters

htmlHelper
Type: System.Web.Mvc.HtmlHelper<TModel>

The HTML helper instance that this method extends.

expression
Type: System.Linq.Expressions.Expression<Func<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<TModel, TProperty> Method (HtmlHelper<TModel>, Expression<Func<TModel, TProperty>>, String, Object, String)

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

public static MvcHtmlString ValidationMessageFor<TModel, TProperty>(
	this HtmlHelper<TModel> htmlHelper,
	Expression<Func<TModel, TProperty>> expression,
	string validationMessage,
	object htmlAttributes,
	string tag
)

Parameters

htmlHelper
Type: System.Web.Mvc.HtmlHelper<TModel>

The HTML helper instance that this method operates on.

expression
Type: System.Linq.Expressions.Expression<Func<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<TModel, TProperty> Method (HtmlHelper<TModel>, Expression<Func<TModel, TProperty>>, String, String)

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

public static MvcHtmlString ValidationMessageFor<TModel, TProperty>(
	this HtmlHelper<TModel> htmlHelper,
	Expression<Func<TModel, TProperty>> expression,
	string validationMessage,
	string tag
)

Parameters

htmlHelper
Type: System.Web.Mvc.HtmlHelper<TModel>

The HTML helper instance that this method operates on.

expression
Type: System.Linq.Expressions.Expression<Func<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: