HtmlHelperValidationExtensions.ValidationMessageFor Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
ValidationMessageFor<TModel,TResult>(IHtmlHelper<TModel>, Expression<Func<TModel,TResult>>, String, Object) |
Returns the validation message if an error exists in the ModelStateDictionary
object for the specified |
ValidationMessageFor<TModel,TResult>(IHtmlHelper<TModel>, Expression<Func<TModel,TResult>>, String, String) |
Returns the validation message if an error exists in the ModelStateDictionary
object for the specified |
ValidationMessageFor<TModel,TResult>(IHtmlHelper<TModel>, Expression<Func<TModel,TResult>>) |
Returns the validation message if an error exists in the ModelStateDictionary
object for the specified |
ValidationMessageFor<TModel,TResult>(IHtmlHelper<TModel>, Expression<Func<TModel,TResult>>, String) |
Returns the validation message if an error exists in the ModelStateDictionary
object for the specified |
ValidationMessageFor<TModel,TResult>(IHtmlHelper<TModel>, Expression<Func<TModel,TResult>>, String, Object)
Returns the validation message if an error exists in the ModelStateDictionary
object for the specified expression
.
public:
generic <typename TModel, typename TResult>
[System::Runtime::CompilerServices::Extension]
static Microsoft::AspNetCore::Html::IHtmlContent ^ ValidationMessageFor(Microsoft::AspNetCore::Mvc::Rendering::IHtmlHelper<TModel> ^ htmlHelper, System::Linq::Expressions::Expression<Func<TModel, TResult> ^> ^ expression, System::String ^ message, System::Object ^ htmlAttributes);
public static Microsoft.AspNetCore.Html.IHtmlContent ValidationMessageFor<TModel,TResult> (this Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel> htmlHelper, System.Linq.Expressions.Expression<Func<TModel,TResult>> expression, string message, object htmlAttributes);
static member ValidationMessageFor : Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<'Model> * System.Linq.Expressions.Expression<Func<'Model, 'Result>> * string * obj -> Microsoft.AspNetCore.Html.IHtmlContent
<Extension()>
Public Function ValidationMessageFor(Of TModel, TResult) (htmlHelper As IHtmlHelper(Of TModel), expression As Expression(Of Func(Of TModel, TResult)), message As String, htmlAttributes As Object) As IHtmlContent
Type Parameters
- TModel
The type of the model.
- TResult
The type of the expression
result.
Parameters
- htmlHelper
- IHtmlHelper<TModel>
The IHtmlHelper instance this method extends.
- expression
- Expression<Func<TModel,TResult>>
An expression to be evaluated against 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.
- htmlAttributes
- Object
An Object that contains the HTML attributes for the (ValidationMessageElement) element. Alternatively, an IDictionary<TKey,TValue> instance containing the HTML attributes.
Returns
A new IHtmlContent containing a ValidationMessageElement element.
An empty IHtmlContent if the expression
is valid and client-side
validation is disabled.
Applies to
ValidationMessageFor<TModel,TResult>(IHtmlHelper<TModel>, Expression<Func<TModel,TResult>>, String, String)
Returns the validation message if an error exists in the ModelStateDictionary
object for the specified expression
.
public:
generic <typename TModel, typename TResult>
[System::Runtime::CompilerServices::Extension]
static Microsoft::AspNetCore::Html::IHtmlContent ^ ValidationMessageFor(Microsoft::AspNetCore::Mvc::Rendering::IHtmlHelper<TModel> ^ htmlHelper, System::Linq::Expressions::Expression<Func<TModel, TResult> ^> ^ expression, System::String ^ message, System::String ^ tag);
public static Microsoft.AspNetCore.Html.IHtmlContent ValidationMessageFor<TModel,TResult> (this Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel> htmlHelper, System.Linq.Expressions.Expression<Func<TModel,TResult>> expression, string message, string tag);
static member ValidationMessageFor : Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<'Model> * System.Linq.Expressions.Expression<Func<'Model, 'Result>> * string * string -> Microsoft.AspNetCore.Html.IHtmlContent
<Extension()>
Public Function ValidationMessageFor(Of TModel, TResult) (htmlHelper As IHtmlHelper(Of TModel), expression As Expression(Of Func(Of TModel, TResult)), message As String, tag As String) As IHtmlContent
Type Parameters
- TModel
The type of the model.
- TResult
The type of the expression
result.
Parameters
- htmlHelper
- IHtmlHelper<TModel>
The IHtmlHelper instance this method extends.
- expression
- Expression<Func<TModel,TResult>>
An expression to be evaluated against 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.
Returns
A new IHtmlContent containing the tag
element. An empty
IHtmlContent if the expression
is valid and client-side validation is
disabled.
Applies to
ValidationMessageFor<TModel,TResult>(IHtmlHelper<TModel>, Expression<Func<TModel,TResult>>)
Returns the validation message if an error exists in the ModelStateDictionary
object for the specified expression
.
public:
generic <typename TModel, typename TResult>
[System::Runtime::CompilerServices::Extension]
static Microsoft::AspNetCore::Html::IHtmlContent ^ ValidationMessageFor(Microsoft::AspNetCore::Mvc::Rendering::IHtmlHelper<TModel> ^ htmlHelper, System::Linq::Expressions::Expression<Func<TModel, TResult> ^> ^ expression);
public static Microsoft.AspNetCore.Html.IHtmlContent ValidationMessageFor<TModel,TResult> (this Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel> htmlHelper, System.Linq.Expressions.Expression<Func<TModel,TResult>> expression);
static member ValidationMessageFor : Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<'Model> * System.Linq.Expressions.Expression<Func<'Model, 'Result>> -> Microsoft.AspNetCore.Html.IHtmlContent
<Extension()>
Public Function ValidationMessageFor(Of TModel, TResult) (htmlHelper As IHtmlHelper(Of TModel), expression As Expression(Of Func(Of TModel, TResult))) As IHtmlContent
Type Parameters
- TModel
The type of the model.
- TResult
The type of the expression
result.
Parameters
- htmlHelper
- IHtmlHelper<TModel>
The IHtmlHelper instance this method extends.
- expression
- Expression<Func<TModel,TResult>>
An expression to be evaluated against the current model.
Returns
A new IHtmlContent containing a ValidationMessageElement element.
An empty IHtmlContent if the expression
is valid and client-side
validation is disabled.
Remarks
Method extracts an error string from the ModelStateDictionary object. Message will always be visible but client-side validation may update the associated CSS class.
Applies to
ValidationMessageFor<TModel,TResult>(IHtmlHelper<TModel>, Expression<Func<TModel,TResult>>, String)
Returns the validation message if an error exists in the ModelStateDictionary
object for the specified expression
.
public:
generic <typename TModel, typename TResult>
[System::Runtime::CompilerServices::Extension]
static Microsoft::AspNetCore::Html::IHtmlContent ^ ValidationMessageFor(Microsoft::AspNetCore::Mvc::Rendering::IHtmlHelper<TModel> ^ htmlHelper, System::Linq::Expressions::Expression<Func<TModel, TResult> ^> ^ expression, System::String ^ message);
public static Microsoft.AspNetCore.Html.IHtmlContent ValidationMessageFor<TModel,TResult> (this Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel> htmlHelper, System.Linq.Expressions.Expression<Func<TModel,TResult>> expression, string message);
static member ValidationMessageFor : Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<'Model> * System.Linq.Expressions.Expression<Func<'Model, 'Result>> * string -> Microsoft.AspNetCore.Html.IHtmlContent
<Extension()>
Public Function ValidationMessageFor(Of TModel, TResult) (htmlHelper As IHtmlHelper(Of TModel), expression As Expression(Of Func(Of TModel, TResult)), message As String) As IHtmlContent
Type Parameters
- TModel
The type of the model.
- TResult
The type of the expression
result.
Parameters
- htmlHelper
- IHtmlHelper<TModel>
The IHtmlHelper instance this method extends.
- expression
- Expression<Func<TModel,TResult>>
An expression to be evaluated against 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.
Returns
A new IHtmlContent containing a ValidationMessageElement element.
An empty IHtmlContent if the expression
is valid and client-side
validation is disabled.